Skip to main content

A pytest-benchmark matrix, metadata, and JSON results layer.

Project description

benchmatrix

CI Documentation Docker CodeQL OpenSSF Scorecard Workflow lint Python 3.11-3.14 Typed with basedpyright Linted with Ruff Coverage gate: 95% SBOM: CycloneDX 1.6

Benchmark matrices for Python projects that need performance data they can trust, compare, and parse.

benchmatrix sits on top of pytest-benchmark and adds the layer that benchmark suites usually grow by hand: implementation-by-case matrices, strict JSON-safe metadata, metric-aware result parsing, and concise display of saved benchmark runs.

Build repeatable suites Keep metrics honest Parse saved runs
Generate pytest benchmark tests across implementations, cases, and metric views. Separate latency, throughput, and local distribution comparisons instead of mixing unlike numbers. Load benchmatrix-tagged pytest-benchmark JSON rows into structured Python objects.

Quick Start

Create a benchmark matrix from ordinary synchronous callables:

from benchmatrix import BenchmarkCase, make_benchmark_test

implementations = {
    "builtin": sum,
    "loop": lambda vs: sum(v for v in vs),
}

cases = [
    BenchmarkCase.from_values(
        "small",
        list(range(100)),
        work_units=100,
        work_unit_name="items",
    ),
]

test_sum_matrix = make_benchmark_test(implementations, cases)

Run it with pytest-benchmark and keep the machine-readable output:

uv run pytest tests/test_sum_benchmark.py --benchmark-json benchmark.json

Read the tagged rows back later:

from benchmatrix import display_benchmark_rows, load_benchmark_json

rows = load_benchmark_json("benchmark.json")
display_benchmark_rows(rows)

Why It Exists

pytest-benchmark owns timing, calibration, statistics, terminal reporting, and JSON export. benchmatrix owns the repeatable structure around those timings.

Need benchmatrix gives you
Compare multiple implementations One generated pytest benchmark matrix instead of repeated parametrization code.
Track what each timing means JSON-safe invocation metadata with implementation, case, and metric identity.
Report different metric views Single-call latency, logical-work throughput, and local tail-latency summaries.
Reuse benchmark output Parsers and display helpers for pytest-benchmark JSON produced by benchmatrix tests.

benchmatrix is intentionally narrow: it benchmarks synchronous Python callables. It is not a load-testing framework, production latency monitor, or replacement for pytest-benchmark.

Install

For local development from this repository:

make ready

To try the package from another project before the first PyPI release, install from GitHub:

uv add "benchmatrix @ git+https://github.com/ryancswallace/benchmatrix"

Documentation

Start here Use it for
First benchmark A complete first benchmark from test file to parsed JSON.
Create a benchmark matrix Cases, work units, fresh inputs, and synchronous target wrappers.
Parse benchmark results Loading and displaying benchmatrix-tagged pytest-benchmark JSON.
Performance model What the metrics mean and what they do not prove.
Configuration and automation Make targets, CI workflows, Docker checks, docs, and SBOM generation.

The MkDocs site builds in strict mode and generates API reference pages from the package docstrings.

Project Links

License

benchmatrix is distributed under the MIT License.

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

benchmatrix-0.2.3.tar.gz (63.2 kB view details)

Uploaded Source

Built Distribution

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

benchmatrix-0.2.3-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file benchmatrix-0.2.3.tar.gz.

File metadata

  • Download URL: benchmatrix-0.2.3.tar.gz
  • Upload date:
  • Size: 63.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for benchmatrix-0.2.3.tar.gz
Algorithm Hash digest
SHA256 36ff5ae63a63940c150c676635da56206f86fcdbc90d535815547d5ec3573a63
MD5 6ab4b4ff75b8e39ee8029786c4c24a8f
BLAKE2b-256 283c464780e819cb294234b511c7c3634a30d741b1e268650a6bd59f6d34f6a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for benchmatrix-0.2.3.tar.gz:

Publisher: release.yml on ryancswallace/benchmatrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file benchmatrix-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: benchmatrix-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for benchmatrix-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b89b21b5b898e29401bf7037438faa6c6b79af21dcc847204b104422e7953b88
MD5 536b7d185bb34c542e573b42800124cd
BLAKE2b-256 556549cd23555059cd9e4c227605b8a3e4f9b6e0e319a72e830c7cc2a6294e66

See more details on using hashes here.

Provenance

The following attestation bundles were made for benchmatrix-0.2.3-py3-none-any.whl:

Publisher: release.yml on ryancswallace/benchmatrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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