
![]() | a function to call |
![]() | a list of arguments to the function |
![]() | number of calls to make (repetitions) |
![]() | name of function (for printout) |
def timer(func, args, repetitions, func_name):
t0 = time.time(); c0 = time.clock()
for i in range(repetitions):
func(*args) # old style: apply(func, args)
print "%s: elapsed=%g, CPU=%g" % \
(func_name, time.time()-t0, time.clock()-c0)