zerobench 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+
17
+ pre-commit:
18
+ name: Pre-commit
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: j178/prek-action@v1
23
+
24
+ test:
25
+ name: Run tests on Python ${{ matrix.python-version }}
26
+ runs-on: ubuntu-latest
27
+ strategy:
28
+ matrix:
29
+ python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
30
+
31
+ steps:
32
+ - name: Checkout code
33
+ uses: actions/checkout@v4
34
+ with:
35
+ fetch-depth: 0
36
+
37
+ - name: Set up Python ${{ matrix.python-version }}
38
+ uses: actions/setup-python@v5
39
+ with:
40
+ python-version: ${{ matrix.python-version }}
41
+
42
+ - name: Install uv
43
+ uses: astral-sh/setup-uv@v6
44
+ with:
45
+ enable-cache: true
46
+
47
+ - name: Build wheel
48
+ run: uv build --wheel
49
+
50
+ - name: Install project's wheel and dependencies
51
+ run: |
52
+ uv sync --locked --no-install-project
53
+ uv pip install dist/zerobench-*.whl
54
+
55
+ - name: Run tests
56
+ run: |
57
+ source .venv/bin/activate
58
+ pytest -v
@@ -0,0 +1,44 @@
1
+ name: Release to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ publish:
9
+ name: Publish package to PyPI
10
+ runs-on: ubuntu-latest
11
+ environment: release
12
+
13
+ permissions:
14
+ id-token: write
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: '3.10'
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v6
29
+ with:
30
+ enable-cache: true
31
+
32
+ - name: Check tag of last commit
33
+ run: |
34
+ echo "Current tag:"
35
+ git describe --tags --exact-match HEAD
36
+
37
+ - name: Clean uv cache for dynamic versioning
38
+ run: uv cache clean
39
+
40
+ - name: Build package
41
+ run: uv build
42
+
43
+ - name: Publish to PyPI
44
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ dist/
3
+ build/
4
+ /.venv/
5
+ /.idea/
6
+
7
+ *.py[cod]
8
+ .ipynb_checkpoints/
9
+ .DS_Store
10
+
11
+ # Sphinx generated files
12
+ docs/build/
13
+ docs/source/api/generated/
@@ -0,0 +1,66 @@
1
+ repos:
2
+ - repo: https://github.com/asottile/pyupgrade
3
+ rev: "v3.21.2"
4
+ hooks:
5
+ - id: pyupgrade
6
+ args: ["--py310-plus"]
7
+
8
+ - repo: https://github.com/hadialqattan/pycln
9
+ rev: "v2.6.0"
10
+ hooks:
11
+ - id: pycln
12
+ args:
13
+ - --all
14
+
15
+ - repo: https://github.com/PyCQA/isort
16
+ rev: '7.0.0'
17
+ hooks:
18
+ - id: isort
19
+ args:
20
+ - --profile=black
21
+ - --line-length=100
22
+
23
+ - repo: https://github.com/psf/black
24
+ rev: '26.1.0'
25
+ hooks:
26
+ - id: black
27
+ args:
28
+ - --skip-string-normalization
29
+ - --line-length=100
30
+
31
+ - repo: https://github.com/pre-commit/pre-commit-hooks
32
+ rev: 'v6.0.0'
33
+ hooks:
34
+ - id: trailing-whitespace
35
+ - id: end-of-file-fixer
36
+ - id: check-yaml
37
+ - id: double-quote-string-fixer
38
+ - id: check-merge-conflict
39
+ - id: debug-statements
40
+
41
+ - repo: https://github.com/pycqa/flake8
42
+ rev: '7.3.0'
43
+ hooks:
44
+ - id: flake8
45
+ name: flake 8 (src)
46
+ args:
47
+ - --max-line-length=100
48
+ # E203 Whitespace before ':' (black incompatibility)
49
+ # E731 Do not assign a lambda expression, use a def
50
+ - --extend-ignore=E203,E731
51
+ files: ^.*\.py
52
+
53
+ - repo: https://github.com/pre-commit/mirrors-mypy
54
+ rev: 'v1.19.1'
55
+ hooks:
56
+ - id: mypy
57
+ additional_dependencies:
58
+ - jax
59
+ - polars
60
+ - matplotlib
61
+ args:
62
+ - --strict
63
+ - --show-error-codes
64
+ - --enable-error-code=ignore-without-code
65
+ - --allow-untyped-calls
66
+ files: ^zerobench\.py
zerobench-0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pierre Chanial
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
zerobench-0.1/PKG-INFO ADDED
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: zerobench
3
+ Version: 0.1
4
+ Summary: A multidimensional benchmarking library with minimal overhead
5
+ Author: Pierre Chanial
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: matplotlib
10
+ Requires-Dist: polars
11
+ Description-Content-Type: text/markdown
12
+
13
+ # zerobench
14
+
15
+ A Python benchmarking library with zero overhead, designed for multidimensional performance analysis.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install zerobench
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```python
26
+ from zerobench import Benchmark
27
+
28
+ bench = Benchmark()
29
+
30
+ for n in [100, 1000, 10000]:
31
+ data = list(range(n))
32
+ with bench(method='sum', n=n):
33
+ sum(data)
34
+ with bench(method='len', n=n):
35
+ len(data)
36
+ ```
37
+ Output:
38
+ ```text
39
+ method=sum, n=100: 0.579 us ± 2.38 ns (median ± std. dev. of 7 runs, 500000 loops each)
40
+ method=len, n=100: 0.020 us ± 0.45 ns (median ± std. dev. of 7 runs, 20000000 loops each)
41
+ method=sum, n=1000: 5.369 us ± 44.70 ns (median ± std. dev. of 7 runs, 50000 loops each)
42
+ method=len, n=1000: 0.029 us ± 0.09 ns (median ± std. dev. of 7 runs, 10000000 loops each)
43
+ method=sum, n=10000: 53.728 us ± 69.86 ns (median ± std. dev. of 7 runs, 5000 loops each)
44
+ method=len, n=10000: 0.029 us ± 0.25 ns (median ± std. dev. of 7 runs, 10000000 loops each)
45
+ ```
46
+
47
+ ```text
48
+ print(bench)
49
+ ┌────────┬────────┬─────────────────────────────────┐
50
+ │ method ┆ n ┆ execution_times │
51
+ ╞════════╪════════╪═════════════════════════════════╡
52
+ │ sum ┆ 100 ┆ [0.577805, 0.57815, … 0.581231… │
53
+ │ len ┆ 100 ┆ [0.019207, 0.019278, … 0.01958… │
54
+ │ sum ┆ 1_000 ┆ [5.417795, 5.33863, … 5.35146] │
55
+ │ len ┆ 1_000 ┆ [0.028898, 0.030144, … 0.03007… │
56
+ │ sum ┆ 10_000 ┆ [53.743199, 53.664567, … 53.72… │
57
+ │ len ┆ 10_000 ┆ [0.028857, 0.028911, … 0.02942… │
58
+ └────────┴────────┴─────────────────────────────────┘
59
+ ```
60
+
61
+ ## Features
62
+
63
+ - **Context manager API**: Benchmark any code block with `with bench(...): ...`
64
+ - **Multidimensional**: Tag benchmarks with arbitrary keyword arguments
65
+ - **Zero overhead**: Code is passed directly to `timeit.Timer`, no wrapper function
66
+ - **Auto-scaling**: Automatically determines the number of iterations for reliable measurements
67
+ - **Multiple exports**: CSV, Parquet, Markdown
68
+ - **Plotting**: Built-in visualization with matplotlib
69
+
70
+ ## Export and Visualization
71
+
72
+ ```python
73
+ # Export results
74
+ bench.write_csv('results.csv')
75
+ bench.write_parquet('results.parquet')
76
+ bench.write_markdown('results.md')
77
+
78
+ # Plot results
79
+ bench.plot()
80
+ bench.write_plot('results.pdf')
81
+ ```
82
+
83
+ ## Configuration
84
+
85
+ ```python
86
+ Benchmark(
87
+ repeat=7, # Number of measurement repetitions
88
+ min_duration_of_repeat=0.2, # Minimum duration per repeat (seconds)
89
+ time_units='ns', # Time units: 'ns', 'us', 'ms', 's'
90
+ )
91
+ ```
92
+
93
+ ## License
94
+
95
+ MIT
@@ -0,0 +1,83 @@
1
+ # zerobench
2
+
3
+ A Python benchmarking library with zero overhead, designed for multidimensional performance analysis.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install zerobench
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from zerobench import Benchmark
15
+
16
+ bench = Benchmark()
17
+
18
+ for n in [100, 1000, 10000]:
19
+ data = list(range(n))
20
+ with bench(method='sum', n=n):
21
+ sum(data)
22
+ with bench(method='len', n=n):
23
+ len(data)
24
+ ```
25
+ Output:
26
+ ```text
27
+ method=sum, n=100: 0.579 us ± 2.38 ns (median ± std. dev. of 7 runs, 500000 loops each)
28
+ method=len, n=100: 0.020 us ± 0.45 ns (median ± std. dev. of 7 runs, 20000000 loops each)
29
+ method=sum, n=1000: 5.369 us ± 44.70 ns (median ± std. dev. of 7 runs, 50000 loops each)
30
+ method=len, n=1000: 0.029 us ± 0.09 ns (median ± std. dev. of 7 runs, 10000000 loops each)
31
+ method=sum, n=10000: 53.728 us ± 69.86 ns (median ± std. dev. of 7 runs, 5000 loops each)
32
+ method=len, n=10000: 0.029 us ± 0.25 ns (median ± std. dev. of 7 runs, 10000000 loops each)
33
+ ```
34
+
35
+ ```text
36
+ print(bench)
37
+ ┌────────┬────────┬─────────────────────────────────┐
38
+ │ method ┆ n ┆ execution_times │
39
+ ╞════════╪════════╪═════════════════════════════════╡
40
+ │ sum ┆ 100 ┆ [0.577805, 0.57815, … 0.581231… │
41
+ │ len ┆ 100 ┆ [0.019207, 0.019278, … 0.01958… │
42
+ │ sum ┆ 1_000 ┆ [5.417795, 5.33863, … 5.35146] │
43
+ │ len ┆ 1_000 ┆ [0.028898, 0.030144, … 0.03007… │
44
+ │ sum ┆ 10_000 ┆ [53.743199, 53.664567, … 53.72… │
45
+ │ len ┆ 10_000 ┆ [0.028857, 0.028911, … 0.02942… │
46
+ └────────┴────────┴─────────────────────────────────┘
47
+ ```
48
+
49
+ ## Features
50
+
51
+ - **Context manager API**: Benchmark any code block with `with bench(...): ...`
52
+ - **Multidimensional**: Tag benchmarks with arbitrary keyword arguments
53
+ - **Zero overhead**: Code is passed directly to `timeit.Timer`, no wrapper function
54
+ - **Auto-scaling**: Automatically determines the number of iterations for reliable measurements
55
+ - **Multiple exports**: CSV, Parquet, Markdown
56
+ - **Plotting**: Built-in visualization with matplotlib
57
+
58
+ ## Export and Visualization
59
+
60
+ ```python
61
+ # Export results
62
+ bench.write_csv('results.csv')
63
+ bench.write_parquet('results.parquet')
64
+ bench.write_markdown('results.md')
65
+
66
+ # Plot results
67
+ bench.plot()
68
+ bench.write_plot('results.pdf')
69
+ ```
70
+
71
+ ## Configuration
72
+
73
+ ```python
74
+ Benchmark(
75
+ repeat=7, # Number of measurement repetitions
76
+ min_duration_of_repeat=0.2, # Minimum duration per repeat (seconds)
77
+ time_units='ns', # Time units: 'ns', 'us', 'ms', 's'
78
+ )
79
+ ```
80
+
81
+ ## License
82
+
83
+ MIT
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["hatchling", "hatch-vcs"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "zerobench"
7
+ dynamic = ['version']
8
+ description = "A multidimensional benchmarking library with minimal overhead"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Pierre Chanial" }
14
+ ]
15
+ dependencies = [
16
+ "matplotlib",
17
+ "polars",
18
+ ]
19
+
20
+ [dependency-groups]
21
+ dev = [
22
+ {include-group = 'docs'},
23
+ 'pytest>=9.0',
24
+ 'pytest-notebook>=0.10',
25
+ ]
26
+ docs = [
27
+ 'sphinx>=7.0.0',
28
+ 'sphinx-rtd-theme>=1.3.0',
29
+ 'myst-parser>=2.0.0',
30
+ 'nbsphinx>=0.9.0',
31
+ 'jupyter>=1.0.0',
32
+ 'matplotlib>=3.7.0',
33
+ 'numpy>=1.24.0',
34
+ 'pillow>=9.0.0',
35
+ ]
36
+
37
+ [tool.hatch.version]
38
+ source = 'vcs'
@@ -0,0 +1,6 @@
1
+ from importlib.metadata import version as _version
2
+
3
+ from ._benchmark import Benchmark
4
+
5
+ __all__ = ['Benchmark']
6
+ __version__ = _version('zerobench')