I have a problem with timit function for code optimization. For example, I writing functions with parameters in a file, let's call it myfunctions.py
containing :
def func1(X):
Y = X+1
return Y
and I test this function in a second file test.py
where I call the timer function to test code performance (in obviously more complex problems!) containing :
import myfunctions
X0 = 1
t = Timer("Y0 = myfunctions.func1(X0)")
print Y0
print t.timeit()
The Y0
is not calculated, and even if I comment print Y0
line the error global name 'myfunctions' is not defined
occured.
If I specify the setup with the command
t = Timer("Y0 = myfunctions.func1(X0)","import myfunctions")
now the error global name 'X0' is not defined
occurred.
Is someone know how to solve this ? Many thanks.