Benchmark library and CLI
Project description
benchbro
benchbro is a Python benchmarking library and CLI with pytest-style discovery and rich terminal output.
Quick start
Install dependencies:
uv sync --group dev
Create benchmark cases in any importable module:
from benchbro import Case
case = Case(name="hashing", case_type="cpu", metric_type="time", tags=["fast", "core"])
@case.input()
def payload() -> bytes:
return b"benchbro"
@case.benchmark()
def sha1(payload: bytes) -> str:
import hashlib
return hashlib.sha1(payload).hexdigest()
@case.benchmark()
def sha256(payload: bytes) -> str:
import hashlib
return hashlib.sha256(payload).hexdigest()
GC is disabled during measured iterations by default. To keep the interpreter GC behavior unchanged, set:
Case(name="hashing", gc_control="inherit")
Run benchmarks:
uv run benchbro run --repeats 10 --warmup 2
When no target is provided, benchbro discovers benchmarks from:
benchmarks/**/*.py(relative to repo root)
By default, run artifacts are written to .benchbro/:
.benchbro/current.json.benchbro/current.csv
If requested, markdown output can also be written with --output-md.
JSON artifacts include environment metadata for reproducibility (Python/runtime/platform/CPU fields).
CLI basics
Run selected cases/tags and write outputs:
uv run benchbro run my_benchmarks.py \
--case hashing \
--tag fast \
--output-json artifacts/current.json \
--output-csv artifacts/current.csv \
--output-md artifacts/current.md
Compare against a baseline and fail CI on regressions above 5%:
uv run benchbro run my_benchmarks.py \
--baseline-json artifacts/baseline.json \
--fail-on-regression 5
Compare two saved runs directly:
uv run benchbro compare artifacts/baseline.json artifacts/current.json --fail-on-regression 5
End-to-end example
For a complete runnable workflow (baseline, candidate, and compare), use:
examples/README.mdmake examples
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 benchbro-0.0.1.tar.gz.
File metadata
- Download URL: benchbro-0.0.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66bb2528e2913252b063b55d76cc2b82d7cc260bd0a88e20856bc46a7fff1256
|
|
| MD5 |
0d73041680c256c7ef43b839647b4f92
|
|
| BLAKE2b-256 |
d957f04c742cc622ed34b3b942669ca2b6c486fb970a1bd54906bf48b0606ab8
|
File details
Details for the file benchbro-0.0.1-py3-none-any.whl.
File metadata
- Download URL: benchbro-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11be0d41dae944721f10f66c23053aa6b26eb1fc4d645fc592c32ed3d15b9b9b
|
|
| MD5 |
ee027ef1bce8b2ef4000951b8ccdbbe8
|
|
| BLAKE2b-256 |
1f58cf4600380427c5826aa29335e2e249712387e83bc182c7db3098a43fc388
|