A pytest-benchmark matrix, metadata, and JSON results layer.
Project description
benchmatrix
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 install the latest release from PyPI:
uv add benchmatrix
or
pip install 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file benchmatrix-0.2.4.tar.gz.
File metadata
- Download URL: benchmatrix-0.2.4.tar.gz
- Upload date:
- Size: 62.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
811b38fe4433dcee8348af651a08b9aeeedd64c08251b75d74a4fd52f6516796
|
|
| MD5 |
6c09220509dc0b5bb591358ec6d8cda0
|
|
| BLAKE2b-256 |
8b6a7a6542e7752fbdaea5d54f4ab374ee0f1a333f9437f869fc90c5cb70f19e
|
Provenance
The following attestation bundles were made for benchmatrix-0.2.4.tar.gz:
Publisher:
release.yml on ryancswallace/benchmatrix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benchmatrix-0.2.4.tar.gz -
Subject digest:
811b38fe4433dcee8348af651a08b9aeeedd64c08251b75d74a4fd52f6516796 - Sigstore transparency entry: 1933274688
- Sigstore integration time:
-
Permalink:
ryancswallace/benchmatrix@a488dec893023e69c1320ddb71b61c2ab7bb245e -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/ryancswallace
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a488dec893023e69c1320ddb71b61c2ab7bb245e -
Trigger Event:
release
-
Statement type:
File details
Details for the file benchmatrix-0.2.4-py3-none-any.whl.
File metadata
- Download URL: benchmatrix-0.2.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a203596e1c13d4ddd2acaec4b37a950e4b4cd7dcbdac024c66016e0e3291829f
|
|
| MD5 |
fbe33b46acf3a5aa92f08a4b8c5bb04a
|
|
| BLAKE2b-256 |
f7d7557ef73f5a66fcb9d7c0220ae22f654825566e56436e824c121abcea5163
|
Provenance
The following attestation bundles were made for benchmatrix-0.2.4-py3-none-any.whl:
Publisher:
release.yml on ryancswallace/benchmatrix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benchmatrix-0.2.4-py3-none-any.whl -
Subject digest:
a203596e1c13d4ddd2acaec4b37a950e4b4cd7dcbdac024c66016e0e3291829f - Sigstore transparency entry: 1933274751
- Sigstore integration time:
-
Permalink:
ryancswallace/benchmatrix@a488dec893023e69c1320ddb71b61c2ab7bb245e -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/ryancswallace
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a488dec893023e69c1320ddb71b61c2ab7bb245e -
Trigger Event:
release
-
Statement type: