Skip to content

Commit 9f96367

Browse files
committed
Initial attempts adopting pytest-perf
1 parent 1d0a0b9 commit 9f96367

File tree

4 files changed

+18
-55
lines changed

4 files changed

+18
-55
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,6 @@ jobs:
2424
- name: Run tests
2525
run: tox
2626

27-
benchmark:
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v2
31-
- name: Setup Python
32-
uses: actions/setup-python@v2
33-
with:
34-
python-version: 3.9
35-
- name: Install tox
36-
run: |
37-
python -m pip install tox
38-
- name: Run benchmarks
39-
run: tox
40-
env:
41-
TOXENV: perf{,-ref}
42-
4327
diffcov:
4428
runs-on: ubuntu-latest
4529
steps:

exercises.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[discovery]
2+
warmup = import importlib_metadata
3+
exercise = importlib_metadata.distribution("ipython")
4+
5+
[entry_points()]
6+
warmup = import importlib_metadata
7+
exercise = importlib_metadata.entry_points()
8+
9+
[cached distribution]
10+
warmup = import importlib_metadata; importlib_metadata.distribution("ipython")
11+
exercise = importlib_metadata.distribution("ipython")
12+
13+
[uncached distribution]
14+
warmup = import importlib, importlib_metadata
15+
exercise = importlib.invalidate_caches(); importlib_metadata.distribution("ipython")

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ testing =
5151
pep517
5252
pyfakefs
5353
flufl.flake8
54+
pytest-perf
5455

5556
docs =
5657
# upstream

tox.ini

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ toxworkdir={env:TOX_WORK_DIR:.tox}
1010
deps =
1111
commands =
1212
pytest {posargs}
13+
passenv =
14+
HOME
1315
usedevelop = True
1416
extras = testing
1517
setenv =
@@ -33,45 +35,6 @@ commands =
3335
diff-cover coverage.xml --compare-branch=origin/main --html-report diffcov.html
3436
diff-cover coverage.xml --compare-branch=origin/main --fail-under=100
3537

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-
52-
[testenv:perf]
53-
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
68-
deps =
69-
{[perf]deps}
70-
git+https://github.com/python/importlib_metadata
71-
commands =
72-
{[perf]commands}
73-
python -m pyperf compare_to --verbose main.json local.json --table
74-
7538
[testenv:release]
7639
skip_install = True
7740
deps =

0 commit comments

Comments
 (0)