Message333476
I converted msg333446 into attached bench.py using perf. Results on my laptop:
vstinner@apu$ ./python -m perf compare_to ref.json inlined.json --table -G
+-------------------------+---------+------------------------------+
| Benchmark | ref | inlined |
+=========================+=========+==============================+
| format('abc') | 74.4 ns | 43.7 ns: 1.70x faster (-41%) |
+-------------------------+---------+------------------------------+
| 'abc'.replace('x', 'y') | 93.0 ns | 57.5 ns: 1.62x faster (-38%) |
+-------------------------+---------+------------------------------+
| (1, 2, 3).index(2) | 92.5 ns | 59.2 ns: 1.56x faster (-36%) |
+-------------------------+---------+------------------------------+
| a.index(2) | 93.6 ns | 59.9 ns: 1.56x faster (-36%) |
+-------------------------+---------+------------------------------+
| 'abc'.ljust(5) | 124 ns | 86.0 ns: 1.44x faster (-30%) |
+-------------------------+---------+------------------------------+
| math.pow(0.5, 2.0) | 121 ns | 88.1 ns: 1.37x faster (-27%) |
+-------------------------+---------+------------------------------+
The speedup on my laptop is between 30.7 and 38.0 ns per function call, on these specific functions.
1.7x faster on format() is very welcome, well done Serhiy!
Note: You need the just released perf 1.6.0 version to run this benchmark ;-) |
|
Date |
User |
Action |
Args |
2019-01-11 15:12:09 | vstinner | set | recipients:
+ vstinner, scoder, larry, serhiy.storchaka, xtreak |
2019-01-11 15:12:07 | vstinner | set | messageid: <1547219527.5.0.219646816475.issue35582@roundup.psfhosted.org> |
2019-01-11 15:12:07 | vstinner | link | issue35582 messages |
2019-01-11 15:12:07 | vstinner | create | |
|