8000 Merge pull request #294 from python/feature/perf-diff · python/importlib_metadata@f5ce7c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f5ce7c1

Browse files
authored
Merge pull request #294 from python/feature/perf-diff
Employ pyperf and separate environments to compare performance
2 parents 2a2b782 + a9f8a1e commit f5ce7c1

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Run benchmarks
3636
run: tox
3737
env:
38-
TOXENV: perf
38+
TOXENV: perf{,-ref}
3939

4040
diffcov:
4141
runs-on: ubuntu-latest

tox.ini

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,44 @@ commands =
3333
diff-cover coverage.xml --compare-branch=origin/main --html-report diffcov.html
3434
diff-cover coverage.xml --compare-branch=origin/main --fail-under=100
3535

36+
[perf]
37+
deps =
38+
ipython
39+
pyperf
40+
path
41+
commands =
42+
python -c "import path; path.Path('{env:SCOPE}.json').remove_p()"
43+
44+
python -m pyperf timeit --name discovery --append {env:SCOPE}.json -s 'import importlib_metadata' 'importlib_metadata.distribution("ipython")'
45+
46+
python -m pyperf timeit --name 'entry_points()' --append {env:SCOPE}.json -s 'import importlib_metadata' 'importlib_metadata.entry_points()'
47+
48+
python -m pyperf timeit --name 'cached distribution' --append {env:SCOPE}.json -s 'import importlib_metadata; importlib_metadata.distribution("ipython")' 'importlib_metadata.distribution("ipython")'
49+
50+
python -m pyperf timeit --name 'uncached distribution' --append {env:SCOPE}.json -s 'import importlib, importlib_metadata' 'importlib.invalidate_caches(); importlib_metadata.distribution("ipython")'
51+
3652
[testenv:perf]
3753
use_develop = False
54+
# change dir to avoid picking up local package.
55+
changedir = {toxworkdir}
56+
setenv =
57+
SCOPE = local
58+
deps = {[perf]deps}
59+
commands = {[perf]commands}
60+
61+
[testenv:perf-ref]
62+
# compare perf results to the main branch
63+
skip_install = True
64+
# change dir to avoid picking up local package.
65+
changedir = {toxworkdir}
66+
setenv =
67+
SCOPE = main
3868
deps =
39-
ipython
69+
{[perf]deps}
70+
git+https://github.com/python/importlib_metadata
4071
commands =
41-
python -c 'print("Simple discovery performance")'
42-
python -m timeit -s 'import importlib_metadata' -- 'importlib_metadata.distribution("ipython")'
43-
python -c 'print("Entry point discovery performance")'
44-
python -m timeit -s 'import importlib_metadata' -- 'importlib_metadata.entry_points()'
45-
python -c 'print("Cached lookup performance")'
46-
python -m timeit -s 'import importlib_metadata; importlib_metadata.distribution("ipython")' -- 'importlib_metadata.distribution("ipython")'
47-
python -c 'print("Uncached lookup performance")'
48-
python -m timeit -s 'import importlib, importlib_metadata' -- 'importlib.invalidate_caches(); importlib_metadata.distribution("ipython")'
72+
{[perf]commands}
73+
python -m pyperf compare_to --verbose main.json local.json --table
4974

5075
[testenv:release]
5176
skip_install = True

0 commit comments

Comments
 (0)
0