source:
codes/mesh_generation/scvt/timer.py
@
974
Last change on this file since 974 was 974, checked in by dubos, 5 years ago | |
---|---|
File size: 381 bytes |
Rev | Line | |
---|---|---|
[974] | 1 | import time |
2 | ||
3 | ############### profiling ################## | |
4 | ||
5 | class Timer(object): | |
6 | def __init__(self, msg, verbose=True): | |
7 | self.msg, self.verbose = msg, verbose | |
8 | def __enter__(self): | |
9 | self.tstart = time.time() | |
10 | def __exit__(self, type, value, traceback): | |
11 | if self.verbose: | |
12 | print('Time spent %s : %s' % (self.msg, time.time() - self.tstart)) |
Note: See TracBrowser
for help on using the repository browser.