py_fun_speed

View page source

Determine Python Execution Speed

Syntax

      y = fun_obj ( x )
      rate = cmpad::fun_speed ( fun_obj, option, min_time )

Prototype

def fun_speed(fun_obj, option, min_time) :
   assert type(option) == dict
   assert type(option['time_setup'] ) == bool
   assert type(min_time) == float
   # ...
   assert type(rate) == float
   return rate

fun_obj

We are testing the speed of the evaluation of this cpp_fun_obj .

x

This is a vector like object x for the function object.

y

This is the vector like object y for the function object.

option

This python dictionary is used to setup the function object.

time_setup

If option['time_setup'] is true (false) the setup function is (is not) included in the time for each function evaluation. If the setup time is not included, the only thing that changes between function evaluations is the argument vector x .

min_time

This is the minimum time in seconds for the timing of the computation. The computation of the function object will be repeated enough times so that this minimum time is reached.

rate

This is the speed of one computation of the function object; i.e., the number of times per second that the function object gets computed.

Example

xam_fun_speed.py is an example and test that uses this function.