pytest-profiling
Profiling plugin for py.test
What it is and what it does
pytest-profiling is a pytest plugin that automatically profiles test execution using Python's built-in cProfile module and outputs results as human-readable tables or SVG call graphs. When you run pytest with the --profile flag, the plugin captures CPU time and call counts for every function invoked during each test, then aggregates results into a combined.prof file alongside individual per-test profile files stored in a prof/ directory. The --profile-svg option generates visual heat graphs using gprof2dot and Graphviz, making it easy to spot performance bottlenecks at a glance.
The plugin integrates seamlessly into pytest's test discovery and execution flow, requiring only a one-line fixture registration. It depends on six, pytest, and gprof2dot as runtime dependencies. The package is stable (Production/Stable status) and supports Python 3.6 through 3.12, though maintenance is aging—the last release was in late 2024 and the repository shows no recent activity. It is well-suited for developers who need to identify slow tests or understand where CPU time is spent during test runs.
Use it for:
- Identify which tests or test fixtures consume the most CPU time in a large test suite.
- Generate SVG flame graphs to visualize function call hierarchies and spot performance regressions.
- Analyze pstats files offline using Python's pstats module for deeper investigation of test performance.
- Detect unexpected slowdowns in test execution after code changes by comparing prof files.
- Profile integration tests that exercise multiple layers of an application to find bottlenecks.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pytest plugin that profiles test execution using cProfile and generates tabular or SVG heat graph output of performance data.
Yes, if you need to profile test performance. The plugin is stable, has low install friction, carries no license restrictions, and integrates directly into pytest with minimal configuration. The aging maintenance status (last release 623 days ago) is a minor concern but not a blocker—the package is feature-complete and no known vulnerabilities exist. Install it when you need to understand where CPU time goes during testing.
Install
pytest-profiling on PyPI
pip
pip install pytest-profilinguv
uv add pytest-profilingpoetry
poetry add pytest-profilingInstalling pytest-profiling
Before you install
Low friction install with only three runtime dependencies (six, pytest, gprof2dot). Maintenance status is aging—last release was 623 days ago—but the repository remains active and the package supports current Python versions (3.6–3.12).
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install pytest-profiling
# In conftest.py or test file:
pytest_plugins = ['pytest_profiling']
# Run tests with profiling:
# pytest tests/ --profile
# pytest tests/ --profile-svg
Graphviz (dot command) must be installed on the system to generate SVG output with --profile-svg.
Verify before relying
- Whether pstats files are automatically cleaned up or retained indefinitely in the prof/ directory.
- Performance overhead of profiling on test suites with thousands of tests.
- Compatibility with pytest plugins that also instrument test execution.
Package facts
| License | MIT license (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — six, pytest, gprof2dot |
| Maintenance | aging — 623 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,867,549/month — #3,476 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_profiling-1.8.1-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
flameprofConverts Python cProfile statistics into…
permissive · top 15,000 on PyPI
gprof2dotConverts profiler output from many sources…
copyleft · top 5,000 on PyPI
pyprof2calltreeConverts Python cProfile profiling data into…
permissive · top 15,000 on PyPI
django-cprofile-middlewareMiddleware that profiles Django view execution…
permissive · top 15,000 on PyPI
fastapi-profilerIntegrates pyinstrument profiling into FastAPI…
permissive · top 15,000 on PyPI
pytest-shutilProvides pytest fixtures and utilities for…
permissive · top 15,000 on PyPI
pytest-replayA pytest plugin that records test execution…
permissive · top 15,000 on PyPI
line-profilerline_profiler measures execution time on a…
permissive · top 5,000 on PyPI
pytest-fixture-configProvides configuration objects and decorators…
permissive · top 15,000 on PyPI
pytest-loggingA pytest plugin that configures Python logging…
permissive · top 15,000 on PyPI