I originally made a custom function for timing functions that looks like this:
def timefunc(function, *args):
start = time.time()
data = function(*args)
end = time.time()
time_taken = end - start
print "Function: "+function.__name__
print "Time taken:",time_taken
return data
Now, having learned about the timeit module, I want to implement the same thing using that. I just can't figure out how to do it while sending it the function and *args arguments. I have already figured out that I have to do this in the setup arg:
"from __main__ import function"
But I can't figure out what to do about *args, since both the 'stmt' and 'setup' arguments are strings, how can I pass the variables?