A multidimensional benchmarking library with minimal overhead
Project description
zerobench
A Python benchmarking library with zero overhead, designed for multidimensional performance analysis.
Installation
pip install zerobench
Usage
from zerobench import Benchmark
bench = Benchmark()
for n in [100, 1000, 10000]:
data = list(range(n))
with bench(method='sum', n=n):
sum(data)
with bench(method='len', n=n):
len(data)
Output:
method=sum, n=100: 0.579 us ± 2.38 ns (median ± std. dev. of 7 runs, 500000 loops each)
method=len, n=100: 0.020 us ± 0.45 ns (median ± std. dev. of 7 runs, 20000000 loops each)
method=sum, n=1000: 5.369 us ± 44.70 ns (median ± std. dev. of 7 runs, 50000 loops each)
method=len, n=1000: 0.029 us ± 0.09 ns (median ± std. dev. of 7 runs, 10000000 loops each)
method=sum, n=10000: 53.728 us ± 69.86 ns (median ± std. dev. of 7 runs, 5000 loops each)
method=len, n=10000: 0.029 us ± 0.25 ns (median ± std. dev. of 7 runs, 10000000 loops each)
print(bench)
┌────────┬────────┬─────────────────────────────────┐
│ method ┆ n ┆ execution_times │
╞════════╪════════╪═════════════════════════════════╡
│ sum ┆ 100 ┆ [0.577805, 0.57815, … 0.581231… │
│ len ┆ 100 ┆ [0.019207, 0.019278, … 0.01958… │
│ sum ┆ 1_000 ┆ [5.417795, 5.33863, … 5.35146] │
│ len ┆ 1_000 ┆ [0.028898, 0.030144, … 0.03007… │
│ sum ┆ 10_000 ┆ [53.743199, 53.664567, … 53.72… │
│ len ┆ 10_000 ┆ [0.028857, 0.028911, … 0.02942… │
└────────┴────────┴─────────────────────────────────┘
Features
- Context manager API: Benchmark any code block with
with bench(...): ... - Multidimensional: Tag benchmarks with arbitrary keyword arguments
- Zero overhead: Code is passed directly to
timeit.Timer, no wrapper function - Auto-scaling: Automatically determines the number of iterations for reliable measurements
- Multiple exports: CSV, Parquet, Markdown
- Plotting: Built-in visualization with matplotlib
Export and Visualization
# Export results
bench.write_csv('results.csv')
bench.write_parquet('results.parquet')
bench.write_markdown('results.md')
# Plot results
bench.plot()
bench.write_plot('results.pdf')
Configuration
Benchmark(
repeat=7, # Number of measurement repetitions
min_duration_of_repeat=0.2, # Minimum duration per repeat (seconds)
time_units='ns', # Time units: 'ns', 'us', 'ms', 's'
)
License
MIT
Project details
Release history Release notifications | RSS feed
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 zerobench-0.1.tar.gz.
File metadata
- Download URL: zerobench-0.1.tar.gz
- Upload date:
- Size: 158.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
967d405fcdab94851a533f85520f05f481d684e6426d3c01a6cfb14732c29bd3
|
|
| MD5 |
6c9f4a77dcccc4d1429793c3ab0f1e94
|
|
| BLAKE2b-256 |
866f73be2bf5affff3e2e0db48c3161824b30805a86330451aa67bf9104a5a32
|
Provenance
The following attestation bundles were made for zerobench-0.1.tar.gz:
Publisher:
release.yml on pchanial/zerobench
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zerobench-0.1.tar.gz -
Subject digest:
967d405fcdab94851a533f85520f05f481d684e6426d3c01a6cfb14732c29bd3 - Sigstore transparency entry: 956938470
- Sigstore integration time:
-
Permalink:
pchanial/zerobench@f7cb12fa5826df59ecf5e1bf18e0e15d5de09cc7 -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/pchanial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f7cb12fa5826df59ecf5e1bf18e0e15d5de09cc7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file zerobench-0.1-py3-none-any.whl.
File metadata
- Download URL: zerobench-0.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fedc67af10b4bb12d5d09286a099e56369a668f210c0ec257f83fc12c0fe10d
|
|
| MD5 |
9ec8c08de5fd3067c6e8a1336eaf6638
|
|
| BLAKE2b-256 |
0140bb85a067af5c50999a6f558b5d40bcecc00eb8e4ccf0b27ab0c2e51636cb
|
Provenance
The following attestation bundles were made for zerobench-0.1-py3-none-any.whl:
Publisher:
release.yml on pchanial/zerobench
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zerobench-0.1-py3-none-any.whl -
Subject digest:
7fedc67af10b4bb12d5d09286a099e56369a668f210c0ec257f83fc12c0fe10d - Sigstore transparency entry: 956938505
- Sigstore integration time:
-
Permalink:
pchanial/zerobench@f7cb12fa5826df59ecf5e1bf18e0e15d5de09cc7 -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/pchanial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f7cb12fa5826df59ecf5e1bf18e0e15d5de09cc7 -
Trigger Event:
release
-
Statement type: