skillfed

pytest-codspeed

Pytest plugin to create CodSpeed benchmarks

pytest-codspeed v5.0.3 2.9M downloads/30d#2,844 on PyPI133
Permissive 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) Active released

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-codspeed

uv

uv add pytest-codspeed

poetry

poetry add pytest-codspeed

Installing 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

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.9Topic :: Software Development :: TestingTopic :: System :: BenchmarkTopic :: UtilitiesTyping :: Typed

Tags

pytest performance benchmarkingmeasure code execution time pytestperformance testing pluginbenchmark fixture pytestcodspeed integrationperformance regression detection
performance-testingci-cd-integrationbenchmark

More Utilities packages