Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ omit =
tests/*
prepare/*
*/_itertools.py
exercises.py

[report]
show_missing = True
16 changes: 0 additions & 16 deletions 16 .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@ jobs:
- name: Run tests
run: tox

benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install tox
run: |
python -m pip install tox
- name: Run benchmarks
run: tox
env:
TOXENV: perf{,-ref}

diffcov:
runs-on: ubuntu-latest
steps:
Expand Down
36 changes: 36 additions & 0 deletions 36 exercises.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pytest_perf.deco import extras


@extras('perf')
def discovery_perf():
"discovery"
import importlib_metadata # end warmup

importlib_metadata.distribution('ipython')


def entry_points_perf():
"entry_points()"
import importlib_metadata # end warmup

importlib_metadata.entry_points()


@extras('perf')
def cached_distribution_perf():
"cached distribution"
import importlib_metadata

importlib_metadata.distribution('ipython') # end warmup
importlib_metadata.distribution('ipython')


@extras('perf')
def uncached_distribution_perf():
"uncached distribution"
import importlib
import importlib_metadata

# end warmup
importlib.invalidate_caches()
importlib_metadata.distribution('ipython')
1 change: 1 addition & 0 deletions 1 setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ testing =
pep517
pyfakefs
flufl.flake8
pytest-perf >= 0.9.2

docs =
# upstream
Expand Down
41 changes: 2 additions & 39 deletions 41 tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ toxworkdir={env:TOX_WORK_DIR:.tox}
deps =
commands =
pytest {posargs}
passenv =
HOME
usedevelop = True
extras = testing
setenv =
Expand All @@ -33,45 +35,6 @@ commands =
diff-cover coverage.xml --compare-branch=origin/main --html-report diffcov.html
diff-cover coverage.xml --compare-branch=origin/main --fail-under=100

[perf]
deps =
ipython
pyperf
path
commands =
python -c "import path; path.Path('{env:SCOPE}.json').remove_p()"

python -m pyperf timeit --name discovery --append {env:SCOPE}.json -s 'import importlib_metadata' 'importlib_metadata.distribution("ipython")'

python -m pyperf timeit --name 'entry_points()' --append {env:SCOPE}.json -s 'import importlib_metadata' 'importlib_metadata.entry_points()'

python -m pyperf timeit --name 'cached distribution' --append {env:SCOPE}.json -s 'import importlib_metadata; importlib_metadata.distribution("ipython")' 'importlib_metadata.distribution("ipython")'

python -m pyperf timeit --name 'uncached distribution' --append {env:SCOPE}.json -s 'import importlib, importlib_metadata' 'importlib.invalidate_caches(); importlib_metadata.distribution("ipython")'

[testenv:perf]
use_develop = False
# change dir to avoid picking up local package.
changedir = {toxworkdir}
setenv =
SCOPE = local
deps = {[perf]deps}
commands = {[perf]commands}

[testenv:perf-ref]
# compare perf results to the main branch
skip_install = True
# change dir to avoid picking up local package.
changedir = {toxworkdir}
setenv =
SCOPE = main
deps =
{[perf]deps}
git+https://github.com/python/importlib_metadata
commands =
{[perf]commands}
python -m pyperf compare_to --verbose main.json local.json --table

[testenv:release]
skip_install = True
deps =
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.