[issue35884] Add variable access benchmark to Tools/Scripts
Raymond Hettinger
report at bugs.python.org
Fri Feb 1 15:34:35 EST 2019
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
Here's what the output looks like (here am comparing a fresh Py3.8 with Clang versus the same build with GCC-8):
$ make distclean && ./configure && make
$ py Tools/scripts/var_access_benchmark.py
Speed of different kinds of variable accesses:
4.2 μs read_local
4.7 μs read_nonlocal
13.7 μs read_global
18.5 μs read_builtin
18.2 μs read_classvar
26.8 μs read_instancevar
20.3 μs read_instancevar_slots
19.1 μs read_namedtuple
26.9 μs read_boundmethod
4.5 μs write_local
4.8 μs write_nonlocal
18.8 μs write_global
89.9 μs write_classvar
37.1 μs write_instancevar
25.7 μs write_instancevar_slots
0.3 μs loop_overhead
$ make distclean && ./configure CC=gcc-8 && make
$ py Tools/scripts/var_access_benchmark.py
Speed of different kinds of variable accesses:
4.0 μs read_local
4.2 μs read_nonlocal
11.4 μs read_global
16.3 μs read_builtin
16.4 μs read_classvar
24.8 μs read_instancevar
20.1 μs read_instancevar_slots
16.8 μs read_namedtuple
23.2 μs read_boundmethod
4.3 μs write_local
4.5 μs write_nonlocal
15.4 μs write_global
89.4 μs write_classvar
33.5 μs write_instancevar
24.5 μs write_instancevar_slots
0.3 μs loop_overhead
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35884>
_______________________________________
More information about the Python-bugs-list
mailing list