I would like to optimize a function 'myfunc()'. I have several ways to write it, and I would like to check the fastest code. For that, we can use the 'timeit' module. But there are several ways to use it. The most obvious, and apparently the most used, is:
import timeit
timeit.Timer('myfunc()', "from __main__ import myfunc").timeit(100000)
which is similar to
timeit.timeit('myfunc()', "from __main__ import myfunc", number=100000)
But we can also used such code:
min(timeit.Timer('myfunc()', "from __main__ import myfunc").repeat(repeat=100000, number=1))*100000
I was expecting the last one to be the most accurate processing time, but it doesn't seem to be the most used code.
Could you help me to determine when it is better to use timeit.timeit, and when repeat is more appropriate?
Thanks in advance