I am using an IPython 6.2.1 integration with Eclipse/PyDev on Ubuntu. Python version is 3.5.2.
I often see people timing a script like
>>>%timeit for _ in range(1000): True
10000 loops, best of 3: 37.8 µs per loop
When I perform the same operation, my output is
>>>%timeit for _ in range(1000): True
20.8 µs ± 353 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
Imho, "best of 3" is the better measure, so I would like to change my output.
I read both, the IPython and the Python timeit documentation. They both don't even mention, that the output could differ from "best of 3". Is this a question of Linux/Eclipse/PyDev implementation or is there a way to change the output of the timeit
module?
P.S.: The same happens in the Eclipse console, when I use timeit
, so IPython is probably irrelevant here.
>>>timeit '"-".join(str(n) for n in range(100))'
11 ns ± 0.0667 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
Unutbu pointed out that you can achieve the desired behaviour from within a program. Running the first script calling timeit.main()
here indeed returns the best of 3. But I would prefer a version that I can run interactively in the Eclipse console.