skillfed

pytest-profiling

Profiling plugin for py.test

pytest-profiling v1.8.1 1.9M downloads/30d#3,476 on PyPI598
Permissive license MIT license AGING released

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

uv

uv add pytest-profiling

poetry

poetry add pytest-profiling

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: POSIXProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Software Development :: TestingTopic :: Utilities

Tags

pytest profiling plugintest performance profilingcProfile pytest integrationtest execution analysisprofile test runtimepytest performance visualizationtest bottleneck detection
profilingperformance-analysistest-debugging

More Libraries packages