Skip to main content

Run performance tests against the mainline code.

Project description

https://img.shields.io/pypi/v/pytest-perf.svg https://img.shields.io/pypi/pyversions/pytest-perf.svg tests Ruff https://img.shields.io/badge/skeleton-2026-informational

Run performance tests against the mainline code.

Usage

To use it, include pytest-perf in the test dependencies for your project, then create some Python module in your package. The plugin will include any module that contains the text “pytest_perf” and will run performance tests on each function containing “perf” (or “import_time”) in the name.

Tests don’t execute the module directly, but instead parse out the code of the function in two parts, the warmup and the test, separated by a “# end warmup” comment, and then passes those to the timeit module.

See the exercises.py module for example usage.

Import latency

timeit cannot measure the cost of importing a module, because after the first loop the module is cached in sys.modules and subsequent loops only measure the cache lookup. To measure import latency instead, name the function with import_time (in place of perf) and let its body perform the import:

def check_import_time():
    import importlib_metadata

Such a function is traced with python -X importtime in a fresh interpreter (sampled a few times, reporting the fastest) rather than timed with timeit, capturing the real cold-import cost against both the control and the experiment.

Design

pytest-perf works by creating two installs, the control and the experiment, and measuring the performance of some python code against each.

Under the hood, it uses pip-run to install from the upstream main branch (e.g. https://github.com/jaraco/pytest-perf) for the control and from . for the experiment. It then runs each of the experiments against each of the enviroments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_perf-0.17.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_perf-0.17.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_perf-0.17.0.tar.gz.

File metadata

  • Download URL: pytest_perf-0.17.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pytest_perf-0.17.0.tar.gz
Algorithm Hash digest
SHA256 4772518a8794a97eb1b5a99803ea042330fd6454ba746ab63c8e8c2cb1ee4bc8
MD5 543c0ec4930d8308a7bde7314e6e0351
BLAKE2b-256 aceb0ad728b352eef60e1495c43d39f36a03ad3be3583d8ae9ba791f99a13f84

See more details on using hashes here.

File details

Details for the file pytest_perf-0.17.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_perf-0.17.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pytest_perf-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5eba7e627c98ad048657df5dbc4a0d6db08812f8adc9734c48840f96c5a7c613
MD5 bde192488e640b3299e90ddb5d81f827
BLAKE2b-256 b06cd64027064f309343a4bdf341257085b5f529f855b932bb4bb82ec106b9fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page