This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients brett.cannon, lemburg, ned.deily, pitrou, python-dev, rhettinger, serhiy.storchaka, steven.daprano, tim.peters, vstinner
Date 2016-10-18.16:21:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1476807683.67.0.447996506339.issue28240@psf.upfronthosting.co.za>
In-reply-to
Content
Serhiy Storchaka:
>> * autorange: start with 1 loop instead of 10 for slow benchmarks like time.sleep(1)
> This is good if you run relatively slow benchmark, but it makes the result less reliable. You always can specify -n1, but on your own risk.

Sorry, I don't understand how running 1 iteration instead of 10 makes the benchmark less reliable. IMO the reliability is more impacted by the number of repeatitions (-r). I changed the default from 3 to 5 repetitions, so timeit should be *more* reliable in Python 3.7 than 3.6.

> Even "pass" takes at least 0.02 usec on my computer. What you want to measure that takes < 1 ns? I think timeit is just wrong tool for this.

It's just a matter of formatting. IMO clocks have a precision good enough to display nanoseconds when the benchmark uses many iterations (which is the case by default since autorange uses a minimum of 200 ms per benchmark).

Before:

$ python3.6 -m timeit 'pass'
100000000 loops, best of 3: 0.0339 usec per loop

After:

$ python3.7 -m timeit 'pass'
10000000 loops, best of 5: 33.9 nsec per loop

IMO "33.9" is more readable than "0.0339".
History
Date User Action Args
2016-10-18 16:21:23vstinnersetrecipients: + vstinner, lemburg, tim.peters, brett.cannon, rhettinger, pitrou, ned.deily, steven.daprano, python-dev, serhiy.storchaka
2016-10-18 16:21:23vstinnersetmessageid: <1476807683.67.0.447996506339.issue28240@psf.upfronthosting.co.za>
2016-10-18 16:21:23vstinnerlinkissue28240 messages
2016-10-18 16:21:23vstinnercreate