pytest-codspeed
Pytest plugin to create CodSpeed benchmarks
What it is and what it does
pytest-codspeed is a pytest plugin that adds performance benchmarking capabilities to your test suite. It lets you mark entire test functions with @pytest.mark.benchmark for automatic measurement, or use a benchmark fixture to measure specific code blocks with fine-grained control. The plugin integrates with CodSpeed, a performance monitoring platform, allowing you to track performance changes over time and detect regressions in CI/CD pipelines.
The plugin supports measurement modes including walltime. You can run benchmarks locally with the --codspeed flag to see timing results in a formatted table, or integrate them into GitHub Actions workflows to report results to CodSpeed on every push and pull request. The package depends on pytest, rich, and importlib-metadata, making it lightweight to add to existing test suites.
Use it for:
- Detect performance regressions in pull requests by running benchmarks in CI and comparing against baseline results.
- Measure the execution time of critical functions locally during development with the --codspeed flag.
- Track performance trends over time by uploading benchmark results to CodSpeed after each commit.
- Benchmark specific code sections precisely using the fixture approach rather than measuring entire test functions.
- Integrate performance testing into your existing pytest workflow without restructuring your test suite.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that integrates performance benchmarking into your test suite, letting you measure code execution time using either a decorator or a fixture for precise control.
Yes. The plugin is actively maintained, has low install friction, carries a permissive MIT license, and integrates seamlessly into existing pytest workflows. It's suitable for teams wanting to track performance without setting up separate benchmarking infrastructure, especially when paired with CodSpeed's cloud service for CI/CD integration.
Install
pytest-codspeed on PyPI
pip
pip install pytest-codspeeduv
uv add pytest-codspeedpoetry
poetry add pytest-codspeedInstalling pytest-codspeed
Before you install
Low friction install with only 3 runtime dependencies (pytest, rich, importlib-metadata). The project is actively maintained with a recent release 84 days ago and shows steady development activity.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install pytest-codspeed
# In your test file:
import pytest
@pytest.mark.benchmark
def test_my_performance():
result = sum(i**2 for i in range(100))
assert result == 55
# Or with the fixture for precise measurement:
def test_with_fixture(benchmark):
result = benchmark(lambda: sum(i**2 for i in range(100)))
assert result == 55
Requires Python 3.9 or later; pytest must be installed.
Verify before relying
- Whether CodSpeed cloud integration requires a paid account or if local benchmarking is fully free.
- Performance overhead of the plugin itself when running non-benchmark tests.
- Whether the plugin works with all pytest versions or has specific compatibility constraints.
Package facts
| License | The MIT License (MIT) Copyright (c) 2022 CodSpeed and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — pytest, rich, importlib-metadata |
| Maintenance | actively maintained — 84 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,883,538/month — #2,844 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_codspeed-5.0.3-py3-none-any.whl
Keywords: codspeed, benchmark, performance, pytest
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pyperfpyperf is a toolkit for writing, running, and…
permissive · top 15,000 on PyPI
pytest-benchmarkA pytest fixture that benchmarks Python…
permissive · top 5,000 on PyPI
asvasv benchmarks Python packages over their…
permissive · top 15,000 on PyPI
codeflash-benchmarkA pytest plugin that adds benchmarking…
unclear · top 15,000 on PyPI
pytest-isortA pytest plugin that automatically checks…
permissive · top 15,000 on PyPI
pytest-rabbitmqA pytest plugin that provides fixtures to start…
copyleft · top 15,000 on PyPI
pytest-durationsA pytest plugin that measures and reports…
permissive · top 5,000 on PyPI
pytest-redisA pytest plugin that provides fixtures for…
copyleft · top 15,000 on PyPI
pytest-github-actions-annotate-failuresA pytest plugin that automatically annotates…
permissive · top 5,000 on PyPI
rtestA Python test runner built in Rust that uses…
permissive · top 15,000 on PyPI