--- id: pytest-codspeed version: "5.0.3" 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) license_treatment: permissive maintenance: active --- # pytest-codspeed — Pytest plugin to create CodSpeed benchmarks License: permissive · Maintenance: active · Downloads: 2.9M/mo ## 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 above — 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 pip install pytest-codspeed uv add pytest-codspeed 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_current - Install friction: low - Maintenance: active - Downloads: 2.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest performance benchmarking, measure code execution time pytest, performance testing plugin, benchmark fixture pytest, codspeed integration, performance regression detection, performance-testing, ci-cd-integration, benchmark [View on SkillFed](https://skillfed.io/packages/pytest-codspeed) · [View on PyPI](https://pypi.org/project/pytest-codspeed/)