Skip to main content

Organise and analyse your pytest benchmarks

Project description

pytest-park

Build Documentation PyPI - Package Version PyPI - Python Version Docs with MkDocs uv linting: ruff ty prek security: bandit Semantic Versions Copier License

Organise and analyse your pytest benchmarks

Features

  • Load pytest-benchmark JSON artifact folders and normalize runs, groups, marks, params, and custom grouping metadata.
  • Compare reference runs against candidate runs over time with per-case and per-group delta summaries.
  • Build custom grouping views with precedence across custom groups, benchmark groups, marks, and params.
  • Associate optional profiler artifacts with benchmark runs for code-level analysis context.
  • Serve an interactive local NiceGUI dashboard for exploratory benchmark comparison.

Installation

With pip:

python -m pip install pytest-park

With uv:

uv add --group test pytest-park

How to use it

# Print version
pytest-park version

# Start interactive mode (no arguments)
pytest-park

# Inspect a benchmark folder
pytest-park load ./benchmarks

# Analyze grouping distribution
pytest-park analyze ./benchmarks --group-by group --group-by param:device

# Compare a candidate run against a named reference tag/run id
pytest-park compare ./benchmarks --reference reference --candidate candidate-v2 --group-by custom:scenario

# Compare latest run against second-latest run when --reference/--candidate are omitted
# By default, this will compare and print details for all methods.
pytest-park compare ./benchmarks

# Compare a specific method only
pytest-park compare ./benchmarks --method test_func1

# Normalize method names by removing configured postfixes
pytest-park analyze ./benchmarks --original-postfix _orig --reference-postfix _ref

# Launch interactive dashboard
pytest-park serve ./benchmarks --reference reference --original-postfix _orig --reference-postfix _ref --host 127.0.0.1 --port 8080

Benchmark folder expectations

  • Input artifacts are pytest-benchmark JSON files (--benchmark-save output) stored anywhere under a folder.
  • Reference selection uses explicit run id or tag metadata (metadata.run_id, metadata.tag, or fallback identifiers).
  • Default comparison baseline is latest vs second-latest run when --reference and --candidate are omitted.
  • Grouping defaults to: custom groups > benchmark group > marks > params.
  • Custom grouping tokens include custom:<key>, group, marks, params, and param:<name>.
  • Method normalization supports optional --original-postfix and --reference-postfix to align benchmark names across implementations.

pytest-benchmark group stats override

If your benchmark method names encode postfixes and parameter segments, you can override pytest_benchmark_group_stats using the helper from this package:

# tests/conftest.py
from pytest_park.pytest_benchmark import default_pytest_benchmark_group_stats


def pytest_benchmark_group_stats(config, benchmarks, group_by):
	return default_pytest_benchmark_group_stats(
		config,
		benchmarks,
		group_by,
		original_postfix="_orig",
		reference_postfix="_ref",
		group_values_by_postfix={
			"_orig": "original",
			"_ref": "reference",
			"none": "unlabeled",
		},
	)

This stores parsed parts in extra_info["pytest_park_name_parts"] with base_name, parameters, and postfix.

If you use postfixes in benchmark names, expose matching pytest-benchmark options in the same conftest.py:

def pytest_addoption(parser):
	parser.addoption("--benchmark-original-postfix", action="store", default="")
	parser.addoption("--benchmark-reference-postfix", action="store", default="")

Docs

uv run mkdocs build -f ./mkdocs.yml -d ./_build/

Update template

copier update --trust -A --vcs-ref=HEAD

Credits

This project was generated with 🚀 python project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_park-0.1.3.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_park-0.1.3-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest_park-0.1.3.tar.gz.

File metadata

  • Download URL: pytest_park-0.1.3.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_park-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1a381096d33a7022ddeb778d66202f1d0ea8df21b254015f0848b49982825247
MD5 0af044229ad74abce86ddbfe79619d8e
BLAKE2b-256 1ffb4058aa2d70291a58d3a9ef9b347356c7ccad55178645109ae4805995bf2f

See more details on using hashes here.

File details

Details for the file pytest_park-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_park-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_park-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 48b7a7f8fe09587f0f82204c650d2ade28c9f469018d855772ecb6175c98be91
MD5 c19822352cbbc8cdc745b745327b0e60
BLAKE2b-256 fcd934e32e8d1edf67ab8b582d628a97a315ca24a75b79117e436bc71783ddde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page