Added new timing helper in python

This commit is contained in:
Guilhem Lavaux 2014-07-28 09:33:08 +02:00
parent 6150597c67
commit 917a45b494
3 changed files with 17 additions and 1 deletions

View file

@ -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

View file

@ -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):