Message351197
"""
./python.exe -m timeit -r11 -s 'import datetime' -s 'a = datetime.datetime.now().isocalendar()'
50000000 loops, best of 11: 8.72 nsec per loop
Let me know if the benchmark code is not appropriate
"""
Hum wait, this benchmark measures the performance of the pass opcode... That's why it's so fast :-) -s 'a = datetime.datetime.now().isocalendar()' is run exactly once for the whole benchmark, not at each benchmark iteration...
I suggest you this microbenchmark instead:
./python.exe -m pyperf timeit -s 'import datetime; dt = datetime.datetime.now()' 'dt.isocalendar()'
For example, on my Fedora 30 with Python 3.7.4, I get:
Mean +- std dev: 108 ns +- 4 ns |
|
Date |
User |
Action |
Args |
2019-09-05 11:16:51 | vstinner | set | recipients:
+ vstinner, tim.peters, rhettinger, belopolsky, taleinat, berker.peksag, serhiy.storchaka, bmispelon, p-ganssle, corona10 |
2019-09-05 11:16:51 | vstinner | set | messageid: <1567682211.48.0.383804719637.issue24416@roundup.psfhosted.org> |
2019-09-05 11:16:51 | vstinner | link | issue24416 messages |
2019-09-05 11:16:51 | vstinner | create | |
|