def checkpoint(self, msg): if mpicomm != None: mpicomm.Barrier() rt = default_timer() - self.checkpoint_time self.checkpoint_time = default_timer() if mpicomm == None or mpicomm.rank == 0: print self.descr, msg, "used", rt return rt
def checkpoint(self, msg): if mpicomm != None: mpicomm.Barrier() rt = default_timer() - self.checkpoint_time self.checkpoint_time = default_timer() if mpicomm == None or mpicomm.rank == 0: print self.descr, msg, 'used', rt return rt
def timeit(f, number=1000000): it = repeat(None, number) e = gc.isenabled() gc.disable() try: t0 = default_timer() for i in it: f() t1 = default_timer() return t1 - t0 finally: if e: gc.enable()
def start(self): if self.start_time != 0: return # already started. if mpicomm != None: mpicomm.Barrier() self.start_time = default_timer() self.checkpoint_time = self.start_time if (mpicomm == None or mpicomm.rank == 0) and not self.brief: print self.descr, self.extra, 'started at', self.start_time - programstart
def start(self): if self.start_time != 0: return # already started. if mpicomm != None: mpicomm.Barrier() self.start_time = default_timer() self.checkpoint_time = self.start_time if (mpicomm == None or mpicomm.rank == 0) and not self.brief: print self.descr, self.extra, "started at", self.start_time - programstart
def used(self): if mpicomm != None: mpicomm.Barrier() newtimer = default_timer() return newtimer - programstart, newtimer - self.start_time
mpicomm = None #try: # import _MPI as MPI # def mpi_timer(): # return MPI.Wtime() # default_timer = mpi_timer # mpicomm = MPI.COMM_WORLD # if mpicomm.rank == 0: print 'using MPI timer', 'precision', MPI.Wtick() #except ImportError: from time import time as default_timer programstart = default_timer() class Session: def __init__(self, descr, brief=True, extra=''): self.descr = descr self.start_time = 0 self.checkpoint_time = 0 self.brief = brief self.extra = extra def __enter__(self): self.start() return self def __exit__(self, type, value, traceback): self.end() def start(self):
mpicomm = None # try: # import _MPI as MPI # def mpi_timer(): # return MPI.Wtime() # default_timer = mpi_timer # mpicomm = MPI.COMM_WORLD # if mpicomm.rank == 0: print 'using MPI timer', 'precision', MPI.Wtick() # except ImportError: from time import time as default_timer programstart = default_timer() class Session: def __init__(self, descr, brief=True, extra=""): self.descr = descr self.start_time = 0 self.checkpoint_time = 0 self.brief = brief self.extra = extra def __enter__(self): self.start() return self def __exit__(self, type, value, traceback): self.end() def start(self):
def timing_wrapper(*args, **kwargs): t0 = default_timer() result = saved(*args, **kwargs) t1 = default_timer() self.timing += t1 - t0 return result