I want to know how a set of parameters affect the performance of a function f
.
I do this to store the execute time of the parameters:
ListOfParam=[param1,param2,param3]
Time=[]
for param in ListOfParam:
start=time.time()
f(param)
end=time.time()
Time.append(end-start)
I am now worrying about whether execution of param1
will affect execution
time of param2
, because some param
would use multiple CPUs of my computer. How to make it fair for all the param
?
You need to use the timeit
Python module. You can read the doc here, and look the examples here. Is better to use this module than implement you own timer, because timeit
handle:
time.time
or time.clock
.Plus: IPython
include the %timeit
magic function for this purposes (source).