A tiny, precise microbenchmarking framework for Python
Project description
PyBench — a microbenchmarking framework for Python
Write small, focused benchmarks with automatic file discovery, simple parameterization, and a clean, minimal CLI.
Run benchmarks with a single command:
pybench path/to/file_or_dir [-k keyword] [-P key=value ...]
✨ Features
- One-line registration: register cases with
bench.bench(...); optionally useBenchContext.start()/end()to measure only the critical section. - Auto-discovery:
pybench <dir>expands**/*bench.py. - Parameterization: generate multiple cases via
params={...}(cartesian product) or per-caseargs/kwargs. - CLI overrides:
-P key=valueto tweak parameters at runtime (no code edits). - Sound timing: high-resolution, monotonic clock; built-in warmup and repeat.
- Nice output: medians, means, and stdev per call (ns) with iterations/repeats.
📦 Installation
- With pip:
pip install pybench
- With uv:
uv pip install pybench
🚀 Usage
- Run benchmarks in a file or directory:
pybench path/to/file_or_dir [-k keyword] [-P key=value ...]
- Examples:
# Filter by keyword in case/file name pybench benches/ -k json # Pass runtime parameters pybench benches/ -P size=1000 -P repeats=10
Tip: use BenchContext.start()/end() when you only want to measure the critical section of your benchmark.
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 pybenchx-0.1.0.tar.gz.
File metadata
- Download URL: pybenchx-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49040c4000621780fa04b151928420910bbe4f80fbc735622513a1edc72a33c8
|
|
| MD5 |
7568e55e4e2764de086d254c4a895d3e
|
|
| BLAKE2b-256 |
c36a199eb77861994b25e4dc7ec6e4a8bbc099688238e6a03e3ce07119c05233
|
File details
Details for the file pybenchx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pybenchx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac9bec0327d3b49d5a987918b2d37fd044999a20be53bad97b3e3c3f78d09432
|
|
| MD5 |
cc9fd12b56eae6c32ca7d531b1c69af8
|
|
| BLAKE2b-256 |
4f516f5359dc0f976ba605b0f56d4e90425099a4e67f7731f4f4ecaeb7feb4fd
|