$npx skillfedfor your agent

pytest-benchmark

A ``pytest`` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer.

Worth itPyPI UtilitiesReleased Nov 202514.2M downloads / moBSD-2-ClausePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_benchmark-5.2.3-py3-none-any.whl
v5.2.3 · released 2025-11-09 · Python >=3.9 · 2 runtime deps: pytest, py-cpuinfo

Yes. pytest-benchmark is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It is the standard tool for pytest-based performance testing and is well-suited for any project that needs to track or optimize function-level performance.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.9 or later and pytest to be installed; benchmarks run via pytest command, not standalone.
  • Low friction install with only two runtime dependencies (pytest and py-cpuinfo).
  • Actively maintained with recent updates for pytest 9.0 compatibility.

License · maintenance · safety

BSD-2-Clause (permissive) — BSD-2-Clause is a permissive license with minimal restrictions; you can use this package in commercial and proprietary projects with only attribution requirements.

last release 2025-11-09 (278 days) · last repo commit 2026-06-16 · 1,444 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 14,224,897 downloads/mo, #1,243 on PyPI

Verify before relying

pip install pytest-benchmark

import time

def test_my_function(benchmark):
    def work():
        time.sleep(0.000001)
    result = benchmark(work)
    assert result is None
  • Exact overhead or accuracy impact of the calibration mechanism on very fast functions.
  • Whether py-cpuinfo is always required or only for CPU-specific timing modes.
  • Performance characteristics when benchmarking code blocks versus individual functions.
Same gist for agents: .md · .json

What it is and what it does

pytest-benchmark is a pytest plugin that turns test functions into performance benchmarks by wrapping code execution in a calibrated timing harness. It groups runs into rounds, automatically adjusting iteration counts to produce stable measurements, and generates comparison reports and histograms. The package integrates directly into pytest's test discovery and reporting, so you write benchmarks as normal test functions that receive a `benchmark` fixture.

The plugin is designed for function-level micro-benchmarking and provides both simple mode (pass a function and arguments) and pedantic mode with explicit control over setup, iterations, rounds, and per-round teardown. It collects CPU info via py-cpuinfo and supports profiling, tracing, and cProfile integration. Results can be compared across runs and exported to CSV.

Use it for

  • Measure and track performance regressions in a CI/CD pipeline by comparing benchmark results across commits.
  • Profile and optimize hot-path functions by running repeated timed iterations with automatic calibration.
  • Generate performance reports and histograms to document the speed of critical algorithms or library functions.
  • Set up parametrized benchmarks to test performance across different input sizes or configurations.
  • Integrate cProfile or tracing into benchmarks to identify bottlenecks in slow functions.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

pytest-benchmark is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It is the standard tool for pytest-based performance testing and is well-suited for any project that needs to track or optimize function-level performance.

Install

pytest-benchmark on PyPI

Before you install

Low friction install with only two runtime dependencies (pytest and py-cpuinfo). Actively maintained with recent updates for pytest 9.0 compatibility.

Requires Python 3.9 or later and pytest to be installed; benchmarks run via pytest command, not standalone.

License in practice

BSD-2-Clause is a permissive license with minimal restrictions; you can use this package in commercial and proprietary projects with only attribution requirements.

Quickstart

pip install pytest-benchmark

import time

def test_my_function(benchmark):
    def work():
        time.sleep(0.000001)
    result = benchmark(work)
    assert result is None

Verify before relying

  • Exact overhead or accuracy impact of the calibration mechanism on very fast functions.
  • Whether py-cpuinfo is always required or only for CPU-specific timing modes.
  • Performance characteristics when benchmarking code blocks versus individual functions.

Package facts

LicenseBSD-2-Clause permissive
Python supportSupports the current Python release >=3.9
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
pytestpy-cpuinfo
MaintenanceActively maintained 278 days since the last release
Last repo commit
First released
Downloads14,224,897 / month, #1,243 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Utilities

Evidence: pytest_benchmark-5.2.3-py3-none-any.whl

Tags

Capabilities
pytest benchmarking fixtureperformance testing pythoncode timing and profilingbenchmark test runnerfunction performance measurementpytest performance plugintiming calibration tool
Topics
performance-testingpytest-pluginprofiling
PyPI keywords
pytestbenchmark

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “benchmark test runner”

  • pytest-benchmarkA pytest fixture that benchmarks Python functions by running them in…
  • asv-runnerProvides core Python benchmark execution code for the ASV…
  • rtestA Python test runner built in Rust that uses static AST analysis for…

Give your agent the search over MCP, or paste the wish link into any chat.

More Utilities packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
charset-normalizer Worth it
PyPI · Utilities · released Aug 2026

Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.

permissive licensepure Python · 3.7+
1.7Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
Pygments Worth it
PyPI · Utilities · released Mar 2026

Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.

Install it if you need to display or transform source code.

BSD-2-Clausepure Python · 3.9+
1.3Bdownloads / mo
six With conditions
PyPI · Libraries · released Dec 2024

Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.

MITpure Python
1.2Bdownloads / mo

See also pytest-codspeed · codeflash-benchmark · asv-runner · google-benchmark · pytest-harvest · pytest-durations · msbench-utils · asv · pyperf · pytest-postgresql

Further reading