Skip to main content

Benchmark library and CLI

Project description

benchbro

benchbro is a Python benchmarking library and CLI with pytest-style discovery and rich terminal output.

Bench Bro Mascot

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()

Regression thresholds default to 50.0 percent warning and 100.0 percent error at the case level, and can be overridden per benchmark:

case = Case(name="hashing", warning_threshold_pct=5.0, regression_threshold_pct=10.0)

@case.benchmark(warning_threshold_pct=2.0, regression_threshold_pct=3.0)
def critical_path(payload: bytes) -> str:
    ...

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 --repeats 10 --warmup 2

When no target is provided, benchbro discovers benchmarks from:

  • benchmarks/**/*.py (relative to repo root)

benchbro compares against the baseline by default (.benchbro/baseline.json). If the baseline is missing, benchbro creates it automatically. If new cases/benchmarks are introduced later, missing entries are merged into baseline. Pass --new-baseline to replace the entire baseline with the current run.

By default, regular runs do not write artifacts. Use explicit output flags (--output-json, --output-csv, --output-md) when needed.

The baseline is always written to:

  • .benchbro/baseline.json

If requested, markdown output can also be written with --output-md.

JSON artifacts include environment metadata for reproducibility (Python/runtime/platform/CPU fields) both at run level and on each benchmark entry.

CLI basics

Run selected cases/tags and write outputs:

uv run benchbro my_benchmarks.py \
  --case hashing \
  --tag fast \
  --output-json artifacts/current.json \
  --output-csv artifacts/current.csv \
  --output-md artifacts/current.md

Compare against baseline:

uv run benchbro my_benchmarks.py

Regression status uses each benchmark's effective thresholds (benchmark override -> case threshold -> defaults):

  • warning default: 50%
  • error threshold default: 100%

The comparison table shows warning and threshold values for each row.

End-to-end example

For a complete runnable workflow (baseline + candidate comparison), use:

  • examples/README.md
  • make 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

benchbro-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

benchbro-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file benchbro-0.1.0.tar.gz.

File metadata

  • Download URL: benchbro-0.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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 benchbro-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a761fd0c48db32d4ba140a8d66cd6f3eb1379f5fd4f0d447fcdddf97d3d3bc4a
MD5 c82056a97ef0e4c9c3c383d79dc26d08
BLAKE2b-256 eabe23509297f7b0471a1470b6fde412835a94784b3647b8af06133a032af125

See more details on using hashes here.

File details

Details for the file benchbro-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: benchbro-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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 benchbro-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf2d7e30e1196e10f71e38c98db1dd77bdcc3eda36bed7ec54a6946a45251e8d
MD5 fa3e312c9b52bc59056c43072f1d4337
BLAKE2b-256 75d66d8fb5cd1a47d3963aa972167b23f87a5462b0801320740095282326e043

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