What is time unit returned by Python's timeit module for multiple repetitions? -
i read time unit returned timeit module seconds.
however, if have multiple repetitions, e.g.
min(timeit.timer('my_function(t)', 'from __main__ import my_function, t') .repeat(repeat=50, number=1000)))
would have divide result 1000 actual seconds per loop, or account that?
yes, total time returned. have divide 1000 if want have time per iteration of loop. simple test have showed easily:
>>> timeit.timeit("import time; time.sleep(1)", number=1) 1.0000581741333008 >>> timeit.timeit("import time; time.sleep(1)", number=5) 5.000285863876343 >>> timeit.repeat("import time; time.sleep(1)", number=5, repeat=3) [5.000285863876343, 5.003287076950073, 5.000286102294922]
Comments
Post a Comment