pyperf
Python module to run and analyze benchmarks
What it is and what it does
pyperf is a Python benchmarking toolkit that automates the process of writing, executing, and analyzing performance tests. It handles the tedious parts of reliable benchmarking—automatic calibration to a time budget, spawning multiple worker processes to reduce noise, computing statistics (mean, standard deviation, percentiles), and detecting unstable results—so you can focus on the code you want to measure. Results are stored in JSON format for later analysis or comparison.
You can use it two ways: as a command-line tool (pyperf timeit) for quick one-off measurements, or by writing a benchmark script that instantiates a Runner and calls timeit() or other measurement methods. The toolkit also provides commands to analyze results (pyperf stats), compare benchmark suites across Python versions (pyperf compare_to), and tune your system for stable benchmarking (pyperf system tune). It depends only on psutil for system introspection.
Use it for:
- Measure the performance of a code snippet or function across multiple runs and detect statistical significance.
- Compare benchmark results across different Python versions or implementations to identify regressions.
- Track memory usage alongside execution time using --track-memory or --tracemalloc options.
- Automate performance testing in CI/CD pipelines by writing benchmark scripts that output JSON results.
- Analyze historical benchmark data to spot trends or anomalies in performance over time.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pyperf is a toolkit for writing, running, and analyzing Python benchmarks with automatic calibration, statistical analysis, and JSON result storage.
Yes. pyperf is a mature, actively maintained toolkit (950 stars, recent commits, MIT license) with low install friction. It solves a real problem—reliable Python benchmarking with statistical rigor—that most developers either skip or implement poorly. Install it if you need to measure performance seriously rather than relying on ad-hoc timeit calls.
Install
pyperf on PyPI
pip
pip install pyperfuv
uv add pyperfpoetry
poetry add pyperfInstalling pyperf
Before you install
Low install friction with a single runtime dependency (psutil). Active maintenance with a recent commit on 2026-08-05 and 950 GitHub stars; last release was 2026-02-07, indicating steady upkeep.
License in practice
MIT license (permissive) means you can use, modify, and distribute pyperf with minimal restrictions in both open-source and commercial projects.
Quickstart
pip install pyperf
import pyperf
runner = pyperf.Runner()
runner.timeit(name="sort a sorted list",
stmt="sorted(s, key=f)",
setup="f = lambda x: x; s = list(range(1000))")
Requires Python 3.9 or newer.
Verify before relying
- Whether the package's memory tracking (--track-memory, --tracemalloc) works reliably across different Python versions and platforms.
- Performance overhead of pyperf's own measurement infrastructure relative to raw timeit.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — psutil |
| Maintenance | actively maintained — 188 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 646,012/month — #5,597 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyperf-2.10.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pytest-codspeedA pytest plugin that integrates performance…
permissive · top 5,000 on PyPI
google-benchmarkProvides Python bindings to Google's C++…
permissive · top 15,000 on PyPI
asvasv benchmarks Python packages over their…
permissive · top 15,000 on PyPI
hdrhistogramRecords and analyzes high-precision latency and…
permissive · top 15,000 on PyPI
pytest-benchmarkA pytest fixture that benchmarks Python…
permissive · top 5,000 on PyPI
bootstrappedBuilds confidence intervals from data samples…
unclear · top 15,000 on PyPI
pystackPyStack inspects the stack frames of a running…
permissive · top 15,000 on PyPI
codeflash-benchmarkA pytest plugin that adds benchmarking…
unclear · top 15,000 on PyPI
fevfev is a lightweight benchmarking library for…
permissive · top 15,000 on PyPI
BottleneckBottleneck provides fast NumPy array functions…
permissive · top 5,000 on PyPI