Package topo :: Package base :: Module simulation :: Class SomeTimer
[hide private]
[frames] | no frames]

Class SomeTimer

source code


Provides a countdown timer for functions that run repeatedly.

There are two distinct ways to use the timer.

The first, via call_and_time(), is for calling some function every specified number of steps for a specified duration. Currently call_and_time() is used for timing calls to simulation.run() every 1.0 steps for 100 iterations. See the Simulation class for an example of using the timer in this way.

The second, via call_fixed_num_times(), is for calling some function repeatedly a specified number of times. A case to use call_fixed_num_times() would be timing pattern presentations, where the number of times the pattern_presenter will be called is known in advance. Additionally, this method allows a list of arguments to be passed to the function (in this case, the permutation for each call).

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
__pass_out_info(self, time, percent, name, duration, remaining) source code
 
__measure(self, fduration, step, arg_list=None) source code
 
call_fixed_num_times(self, args_for_iterations)
Call self.func(args_for_iterations[i]) for all i in args_for_iterations.
source code
 
call_and_time(self, fduration)
Call self.func(self.step or fduration/50.0) for fduration.
source code

Inherited from param.parameterized.Parameterized: __getstate__, __init__, __repr__, __setstate__, __str__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, script_repr, set_default, set_dynamic_time_fn, set_param, state_pop, state_push, verbose, warning

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  step = param.Parameter(default= 2, doc= """Only relevant with ...
Only relevant with call_and_time(), not call_fixed_num_times().
  estimate_interval = param.Number(default= 50, doc= """Interval...
Interval in simulation time between estimates.
  func = param.Parameter(default= None, instantiate= True, doc= ...
Function to be timed.
  simulation_time_fn = param.Parameter(default= None, instantiat...
Function that returns the simulation time.
  real_time_fn = param.Parameter(default= time.time, instantiate...
Function that returns the wallclock time.
  receive_info = param.Parameter(default= [], instantiate= True,...
List of objects that will receive timing information.
  stop = param.Boolean(default= False, doc= """If set to True, e...
If set to True, execution of func (and timing) will cease at the end of the current iteration.
  name = <param.parameterized.String object at 0xa54adac>
String identifier for this object.

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from object: __class__

Class Variable Details [hide private]

step

Only relevant with call_and_time(), not call_fixed_num_times().

Each iteration, func is called as func(step).

For example, step=1 with func set to topo.sim.time would cause the simulation time to advance once per iteration.

The default value (None) gives 50 iterations for any value of simulation_duration passed to call_and_time(simulation_duration).

Value:
param.Parameter(default= 2, doc= """Only relevant with call_and_time(), not call_f\
ixed_num_times(). 
        
           Each iteration, func is called as func(step).
    
           For example, step=1 with func set to topo.sim.time would cause
           the simulation time to advance once per iteration.

...

estimate_interval

Interval in simulation time between estimates.
Value:
param.Number(default= 50, doc= """Interval in simulation time between estimates.""\
")

func

Function to be timed.
Value:
param.Parameter(default= None, instantiate= True, doc= """Function to be timed."""\
)

simulation_time_fn

Function that returns the simulation time.
Value:
param.Parameter(default= None, instantiate= True, doc= """Function that returns th\
e simulation time.""")

real_time_fn

Function that returns the wallclock time.
Value:
param.Parameter(default= time.time, instantiate= True, doc= """Function that retur\
ns the wallclock time.""")

receive_info

List of objects that will receive timing information. Each must have a timing_info() method.
Value:
param.Parameter(default= [], instantiate= True, doc= """List of objects that will \
receive timing information.
        Each must have a timing_info() method.""")

stop

If set to True, execution of func (and timing) will cease at the end of the current iteration.
Value:
param.Boolean(default= False, doc= """If set to True, execution of func (and timin\
g) will cease at the end of
        the current iteration.""")