Added new timing helper in python
This commit is contained in:
parent
6150597c67
commit
917a45b494
3 changed files with 17 additions and 1 deletions
|
@ -4,4 +4,4 @@ from grafic import writeGrafic, writeWhitePhase, readGrafic, readWhitePhase
|
|||
from borg import read_borg_vol
|
||||
from cic import cicParticles
|
||||
from simu import loadRamsesAll, simpleWriteGadget, SimulationBare
|
||||
from timing import timeit, timeit_quiet
|
||||
from timing import time_block, timeit, timeit_quiet
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
import time
|
||||
from contextlib import contextmanager
|
||||
|
||||
@contextmanager
|
||||
def time_block(name):
|
||||
ts = time.time()
|
||||
yield
|
||||
te = time.time()
|
||||
|
||||
print '%s %2.2f sec' % \
|
||||
(name, te-ts)
|
||||
|
||||
def timeit(method):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue