示例#1
0
 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
示例#2
0
 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
示例#3
0
 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()
示例#4
0
 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
示例#5
0
 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
示例#6
0
 def used(self):
     if mpicomm != None:
         mpicomm.Barrier()
     newtimer = default_timer()
     return newtimer - programstart, newtimer - self.start_time
示例#7
0
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):
示例#8
0
 def used(self):
     if mpicomm != None:
         mpicomm.Barrier()
     newtimer = default_timer()
     return newtimer - programstart, newtimer - self.start_time
示例#9
0
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):
示例#10
0
 def timing_wrapper(*args, **kwargs):
     t0 = default_timer()
     result = saved(*args, **kwargs)
     t1 = default_timer()
     self.timing += t1 - t0
     return result