Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
ccbench.TimedLoop Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 func
 args

Detailed Description

Definition at line 157 of file ccbench.py.


Constructor & Destructor Documentation

def ccbench.TimedLoop.__init__ (   self,
  func,
  args 
)

Definition at line 158 of file ccbench.py.

00158 
00159     def __init__(self, func, args):
00160         self.func = func
00161         self.args = args

Here is the caller graph for this function:


Member Function Documentation

def ccbench.TimedLoop.__call__ (   self,
  start_time,
  min_duration,
  end_event,
  do_yield = False 
)

Definition at line 162 of file ccbench.py.

00162 
00163     def __call__(self, start_time, min_duration, end_event, do_yield=False):
00164         step = 20
00165         niters = 0
00166         duration = 0.0
00167         _time = time.time
00168         _sleep = time.sleep
00169         _func = self.func
00170         _args = self.args
00171         t1 = start_time
00172         while True:
00173             for i in range(step):
00174                 _func(*_args)
00175             t2 = _time()
00176             # If another thread terminated, the current measurement is invalid
00177             # => return the previous one.
00178             if end_event:
00179                 return niters, duration
00180             niters += step
00181             duration = t2 - start_time
00182             if duration >= min_duration:
00183                 end_event.append(None)
00184                 return niters, duration
00185             if t2 - t1 < 0.01:
00186                 # Minimize interference of measurement on overall runtime
00187                 step = step * 3 // 2
00188             elif do_yield:
00189                 # OS scheduling of Python threads is sometimes so bad that we
00190                 # have to force thread switching ourselves, otherwise we get
00191                 # completely useless results.
00192                 _sleep(0.0001)
00193             t1 = t2
00194 


Member Data Documentation

Definition at line 160 of file ccbench.py.

Definition at line 159 of file ccbench.py.


The documentation for this class was generated from the following file: