benchcaddy 0.1.0__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.
- benchcaddy-0.1.0/LICENSE +174 -0
- benchcaddy-0.1.0/MANIFEST.in +4 -0
- benchcaddy-0.1.0/PKG-INFO +242 -0
- benchcaddy-0.1.0/README.md +211 -0
- benchcaddy-0.1.0/benchcaddy_logo.png +0 -0
- benchcaddy-0.1.0/examples/benchmark_nonlinear_transform.py +93 -0
- benchcaddy-0.1.0/pyproject.toml +56 -0
- benchcaddy-0.1.0/setup.cfg +4 -0
- benchcaddy-0.1.0/src/benchcaddy/__init__.py +5 -0
- benchcaddy-0.1.0/src/benchcaddy/__main__.py +5 -0
- benchcaddy-0.1.0/src/benchcaddy/cli.py +473 -0
- benchcaddy-0.1.0/src/benchcaddy/core.py +249 -0
- benchcaddy-0.1.0/src/benchcaddy/db.py +559 -0
- benchcaddy-0.1.0/src/benchcaddy/metadata.py +150 -0
- benchcaddy-0.1.0/src/benchcaddy/observability.py +92 -0
- benchcaddy-0.1.0/src/benchcaddy/presentation.py +42 -0
- benchcaddy-0.1.0/src/benchcaddy/reporting.py +137 -0
- benchcaddy-0.1.0/src/benchcaddy.egg-info/PKG-INFO +242 -0
- benchcaddy-0.1.0/src/benchcaddy.egg-info/SOURCES.txt +23 -0
- benchcaddy-0.1.0/src/benchcaddy.egg-info/dependency_links.txt +1 -0
- benchcaddy-0.1.0/src/benchcaddy.egg-info/entry_points.txt +2 -0
- benchcaddy-0.1.0/src/benchcaddy.egg-info/requires.txt +8 -0
- benchcaddy-0.1.0/src/benchcaddy.egg-info/top_level.txt +1 -0
- benchcaddy-0.1.0/tests/test_cli.py +484 -0
- benchcaddy-0.1.0/tests/test_core.py +378 -0
benchcaddy-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
16
|
+
entities that control, are controlled by, or are under common control with that
|
|
17
|
+
entity. For the purposes of this definition, "control" means (i) the power,
|
|
18
|
+
direct or indirect, to cause the direction or management of such entity,
|
|
19
|
+
whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or
|
|
20
|
+
more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
26
|
+
including but not limited to software source code, documentation source, and
|
|
27
|
+
configuration files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object
|
|
31
|
+
code, generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
36
|
+
below).
|
|
37
|
+
|
|
38
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
46
|
+
version of the Work and any modifications or additions to that Work or
|
|
47
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
48
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
49
|
+
Entity authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal, or
|
|
51
|
+
written communication sent to the Licensor or its representatives, including
|
|
52
|
+
but not limited to communication on electronic mailing lists, source code
|
|
53
|
+
control systems, and issue tracking systems that are managed by, or on behalf
|
|
54
|
+
of, the Licensor for the purpose of discussing and improving the Work, but
|
|
55
|
+
excluding communication that is conspicuously marked or otherwise designated in
|
|
56
|
+
writing by the copyright owner as "Not a Contribution."
|
|
57
|
+
|
|
58
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
63
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
64
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
65
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
66
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
67
|
+
Object form.
|
|
68
|
+
|
|
69
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
70
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
71
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
72
|
+
section) patent license to make, have made, use, offer to sell, sell, import,
|
|
73
|
+
and otherwise transfer the Work, where such license applies only to those
|
|
74
|
+
patent claims licensable by such Contributor that are necessarily infringed by
|
|
75
|
+
their Contribution(s) alone or by combination of their Contribution(s) with the
|
|
76
|
+
Work to which such Contribution(s) was submitted. If You institute patent
|
|
77
|
+
litigation against any entity (including a cross-claim or counterclaim in a
|
|
78
|
+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
|
|
79
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
80
|
+
licenses granted to You under this License for that Work shall terminate as of
|
|
81
|
+
the date such litigation is filed.
|
|
82
|
+
|
|
83
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
84
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
85
|
+
Source or Object form, provided that You meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
88
|
+
of this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
91
|
+
You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
94
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
95
|
+
Source form of the Work, excluding those notices that do not pertain to any
|
|
96
|
+
part of the Derivative Works; and
|
|
97
|
+
|
|
98
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
99
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
102
|
+
following places: within a NOTICE text file distributed as part of the
|
|
103
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
104
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
105
|
+
Works, if and wherever such third-party notices normally appear. The contents
|
|
106
|
+
of the NOTICE file are for informational purposes only and do not modify the
|
|
107
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
108
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
109
|
+
provided that such additional attribution notices cannot be construed as
|
|
110
|
+
modifying the License.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
113
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
114
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
115
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
116
|
+
complies with the conditions stated in this License.
|
|
117
|
+
|
|
118
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
119
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
120
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
121
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
122
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
123
|
+
executed with Licensor regarding such Contributions.
|
|
124
|
+
|
|
125
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
126
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
127
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
128
|
+
reproducing the content of the NOTICE file.
|
|
129
|
+
|
|
130
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
131
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
132
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
133
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
134
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
135
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
136
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
137
|
+
associated with Your exercise of permissions under this License.
|
|
138
|
+
|
|
139
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
140
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
141
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
142
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
143
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
144
|
+
character arising as a result of this License or out of the use or inability to
|
|
145
|
+
use the Work (including but not limited to damages for loss of goodwill, work
|
|
146
|
+
stoppage, computer failure or malfunction, or any and all other commercial
|
|
147
|
+
damages or losses), even if such Contributor has been advised of the
|
|
148
|
+
possibility of such damages.
|
|
149
|
+
|
|
150
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
151
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
152
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
153
|
+
and/or rights consistent with this License. However, in accepting such
|
|
154
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
155
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
156
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
157
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
158
|
+
accepting any such warranty or additional liability.
|
|
159
|
+
|
|
160
|
+
END OF TERMS AND CONDITIONS
|
|
161
|
+
|
|
162
|
+
Copyright 2026 Matthias Lenga
|
|
163
|
+
|
|
164
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
165
|
+
you may not use this file except in compliance with the License.
|
|
166
|
+
You may obtain a copy of the License at
|
|
167
|
+
|
|
168
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
169
|
+
|
|
170
|
+
Unless required by applicable law or agreed to in writing, software
|
|
171
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
172
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
173
|
+
See the License for the specific language governing permissions and
|
|
174
|
+
limitations under the License.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: benchcaddy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight benchmark sweeps with environment capture.
|
|
5
|
+
Author: Matthias Lenga
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/MatthiasLen/BenchCaddy
|
|
8
|
+
Project-URL: Repository, https://github.com/MatthiasLen/BenchCaddy
|
|
9
|
+
Project-URL: Issues, https://github.com/MatthiasLen/BenchCaddy/issues
|
|
10
|
+
Keywords: benchmark,performance,profiling,cli,testing
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Testing
|
|
19
|
+
Classifier: Topic :: System :: Benchmark
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: sqlalchemy>=2.0.41
|
|
24
|
+
Requires-Dist: typer>=0.12.5
|
|
25
|
+
Requires-Dist: rich>=13.9.4
|
|
26
|
+
Requires-Dist: gitpython>=3.1.43
|
|
27
|
+
Requires-Dist: psutil>=6.1.1
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8.3; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
<img src="./benchcaddy_logo.png" alt="BenchCaddy logo" width="240"></img>
|
|
33
|
+
|
|
34
|
+
We all tell ourselves we’re going to use Scalene,PyInstrument or TorchProfile - tools that produce traces so complex and beautiful they belong in a modern art gallery. But let’s be real: most days, "benchmarking" is just us sprinkling time.time() across our code like frantic seasoning on a failing dish. You’re staring at the terminal, trying to remember if the last run was actually faster or if you just happen to be in a better mood, only to realize you’ve already lost the thread. *"Wait, when did I change the naming convention of the log files? Is 'results_v2_final' newer than 'results_new_test'?"*
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
**BenchCaddy** is the humble sidekick for those of us living in that chaotic middle ground. It replaces "vibes-based" timing with stabilized sweeps and environment metadata, tucking everything into a neat database before your brain can wander. It won’t map your entire soul, but it will save you from your own memory and provide a summary clean enough to make you look like the organized professional your friends think you are. No traces to decipher, no lost logs, and no more gaslighting yourself - just actual proof your code is getting faster.
|
|
38
|
+
|
|
39
|
+
# Something missing ?
|
|
40
|
+
|
|
41
|
+
BenchCaddy is intentionally lean. I built it to curb my own occasional "log-file-chaos," but I’m curious how you manage yours. If you’ve got a feature idea, a bug that’s getting on your nerves, or a suggestion for an export format that actually belongs in this decade, open an issue. I’m not trying to build a bloated enterprise behemoth; I just want this to be the best way to track performance without ever having to name a file timings_final_v4_fixed_REALLY.log again.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
BenchCaddy is designed around two steps:
|
|
47
|
+
|
|
48
|
+
1. Run a benchmark sweep over one or more configurations.
|
|
49
|
+
2. Inspect or compare the recorded results from the database (e.g. using the CLI).
|
|
50
|
+
|
|
51
|
+
This example stays self-contained and benchmarks a nonlinear iterative transform
|
|
52
|
+
with two variants and two input sizes.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import math
|
|
56
|
+
|
|
57
|
+
from benchcaddy import Sweep, observe
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def initial_signal(size: int) -> list[float]:
|
|
61
|
+
return [
|
|
62
|
+
math.sin(index * 0.013) + 0.5 * math.cos(index * 0.007)
|
|
63
|
+
for index in range(size)
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@observe("nonlinear_iteration")
|
|
68
|
+
def nonlinear_iteration(values: list[float], variant: str) -> list[float]:
|
|
69
|
+
next_values: list[float] = []
|
|
70
|
+
for value in values:
|
|
71
|
+
transformed = (
|
|
72
|
+
math.tanh(value * 1.4)
|
|
73
|
+
+ 0.75 * math.sin(value * value + 0.2)
|
|
74
|
+
+ 0.25 * math.cos(value - 0.1)
|
|
75
|
+
)
|
|
76
|
+
if variant == "stabilized":
|
|
77
|
+
transformed += 0.05 * value * value
|
|
78
|
+
else:
|
|
79
|
+
transformed += 0.03 * math.exp(-(value * value))
|
|
80
|
+
next_values.append(transformed)
|
|
81
|
+
return next_values
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def benchmark_case(size: int, variant: str) -> float:
|
|
85
|
+
values = initial_signal(size)
|
|
86
|
+
for _ in range(8):
|
|
87
|
+
values = nonlinear_iteration(values, variant)
|
|
88
|
+
return sum(abs(value) for value in values)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
Sweep(
|
|
92
|
+
target=benchmark_case,
|
|
93
|
+
params={
|
|
94
|
+
"size": [512, 2048],
|
|
95
|
+
"variant": ["baseline", "stabilized"],
|
|
96
|
+
},
|
|
97
|
+
suite_name="nonlinear-transform",
|
|
98
|
+
samples=5,
|
|
99
|
+
warmup_iterations=1,
|
|
100
|
+
verbose=True,
|
|
101
|
+
).run()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
BenchCaddy writes samples, medians, observations, and environment metadata to
|
|
105
|
+
`benchcaddy.db` in the current working directory.
|
|
106
|
+
|
|
107
|
+
The full runnable example lives in the repository and source distribution at
|
|
108
|
+
[`examples/benchmark_nonlinear_transform.py`](https://github.com/MatthiasLen/BenchCaddy/blob/main/examples/benchmark_nonlinear_transform.py)
|
|
109
|
+
and supports `--verbose`, `--database`, `--samples`, and `--warmup-iterations`.
|
|
110
|
+
|
|
111
|
+
`Sweep` also accepts a script path as the target. In that mode, parameter keys
|
|
112
|
+
are mapped to CLI flags such as `size -> --size` and `warmup_runs` / `iterations`
|
|
113
|
+
can be used as aliases for `warmup_iterations` / `samples`.
|
|
114
|
+
|
|
115
|
+
## Sweep options
|
|
116
|
+
|
|
117
|
+
The main public `Sweep(...)` options are:
|
|
118
|
+
|
|
119
|
+
- `samples`: number of measured samples per configuration
|
|
120
|
+
- `iterations`: alias for `samples`
|
|
121
|
+
- `warmup_iterations`: warmup runs before sampling begins
|
|
122
|
+
- `warmup_runs`: alias for `warmup_iterations`
|
|
123
|
+
- `database_path`: store results in a specific SQLite file instead of `./benchcaddy.db`
|
|
124
|
+
- `lock_cpu_affinity`: preserve the current CPU affinity set before benchmarking
|
|
125
|
+
- `sync`: callable used to synchronize async device work after each invocation
|
|
126
|
+
- `reporter`: custom reporter implementing the `SweepReporter` protocol
|
|
127
|
+
- `verbose=True`: use the built-in Rich reporter during execution
|
|
128
|
+
|
|
129
|
+
## Script targets
|
|
130
|
+
|
|
131
|
+
You can benchmark a standalone script instead of a Python callable:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from benchcaddy import Sweep
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
Sweep(
|
|
138
|
+
target="./train_step.py",
|
|
139
|
+
params={
|
|
140
|
+
"size": [512, 2048],
|
|
141
|
+
"variant": ["baseline", "stabilized"],
|
|
142
|
+
"use_cache": [True, False],
|
|
143
|
+
},
|
|
144
|
+
suite_name="train-step",
|
|
145
|
+
samples=5,
|
|
146
|
+
).run()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
BenchCaddy converts configuration keys to CLI flags:
|
|
150
|
+
|
|
151
|
+
- `size=512` becomes `--size 512`
|
|
152
|
+
- `use_cache=True` becomes `--use-cache`
|
|
153
|
+
- `use_cache=False` becomes `--use-cache false`
|
|
154
|
+
|
|
155
|
+
That mode works best with scripts that parse explicit values for non-presence
|
|
156
|
+
flags and exit with status code `0` on success.
|
|
157
|
+
|
|
158
|
+
## CLI and inspect results
|
|
159
|
+
|
|
160
|
+
List all recorded suites:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
benchcaddy list
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`list` also shows the observation labels seen across runs in each suite.
|
|
167
|
+
|
|
168
|
+
Show the recorded runs and environment for a suite:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
benchcaddy show nonlinear-transform
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Show the detailed timings for a single recorded run:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
benchcaddy show 12
|
|
178
|
+
benchcaddy show 2.3
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Composite run IDs use `SWEEP_ID.RUN_INDEX`, so `2.3` means the third run in
|
|
182
|
+
the second recorded sweep.
|
|
183
|
+
|
|
184
|
+
Show multiple runs side by side in a suite-style view:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
benchcaddy show 4 2.3 1.2
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Compare configurations within a suite by median runtime:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
benchcaddy compare nonlinear-transform
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Compare a suite against a selected recorded run instead of the best run:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
benchcaddy compare nonlinear-transform 2.4
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Restrict a suite comparison to runs that match selected configuration keys from
|
|
203
|
+
the reference run:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
benchcaddy compare nonlinear-transform 2.4 --strict size
|
|
207
|
+
benchcaddy compare nonlinear-transform 2.4 --strict size variant
|
|
208
|
+
benchcaddy compare nonlinear-transform 2.4 --strict variant
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Compare two specific runs directly. Improvements greater than 5% are shown in
|
|
212
|
+
green and regressions greater than 5% are shown in red:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
benchcaddy compare 12 15
|
|
216
|
+
benchcaddy compare 2.3 3
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
For more detail in the inspection output, add `--verbose`:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
benchcaddy --verbose show nonlinear-transform
|
|
223
|
+
benchcaddy --verbose compare nonlinear-transform
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## How to read the output
|
|
227
|
+
|
|
228
|
+
- `Mean +- Std (s)` is the arithmetic mean and sample standard deviation across benchmark samples
|
|
229
|
+
- suite comparisons are ranked by median runtime, not by the mean column
|
|
230
|
+
- `Best Median (s)`, `Delta vs Best`, and direct-run `Median Delta` / `Median Percent Change` all use median runtime
|
|
231
|
+
- observation tables report per-label timing aggregated across samples
|
|
232
|
+
- `Total (s)` in observation tables is the sum across all samples for that label
|
|
233
|
+
|
|
234
|
+
## Environment metadata
|
|
235
|
+
|
|
236
|
+
Every recorded run stores environment details alongside the timing data, including:
|
|
237
|
+
|
|
238
|
+
- Python version and operating system string
|
|
239
|
+
- CPU model and total system memory
|
|
240
|
+
- GPU model when it can be detected
|
|
241
|
+
- Git branch, commit hash, and dirty state when run inside a Git repository
|
|
242
|
+
- process metadata such as PID, priority, affinity, and RSS memory
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<img src="./benchcaddy_logo.png" alt="BenchCaddy logo" width="240"></img>
|
|
2
|
+
|
|
3
|
+
We all tell ourselves we’re going to use Scalene,PyInstrument or TorchProfile - tools that produce traces so complex and beautiful they belong in a modern art gallery. But let’s be real: most days, "benchmarking" is just us sprinkling time.time() across our code like frantic seasoning on a failing dish. You’re staring at the terminal, trying to remember if the last run was actually faster or if you just happen to be in a better mood, only to realize you’ve already lost the thread. *"Wait, when did I change the naming convention of the log files? Is 'results_v2_final' newer than 'results_new_test'?"*
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
**BenchCaddy** is the humble sidekick for those of us living in that chaotic middle ground. It replaces "vibes-based" timing with stabilized sweeps and environment metadata, tucking everything into a neat database before your brain can wander. It won’t map your entire soul, but it will save you from your own memory and provide a summary clean enough to make you look like the organized professional your friends think you are. No traces to decipher, no lost logs, and no more gaslighting yourself - just actual proof your code is getting faster.
|
|
7
|
+
|
|
8
|
+
# Something missing ?
|
|
9
|
+
|
|
10
|
+
BenchCaddy is intentionally lean. I built it to curb my own occasional "log-file-chaos," but I’m curious how you manage yours. If you’ve got a feature idea, a bug that’s getting on your nerves, or a suggestion for an export format that actually belongs in this decade, open an issue. I’m not trying to build a bloated enterprise behemoth; I just want this to be the best way to track performance without ever having to name a file timings_final_v4_fixed_REALLY.log again.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
BenchCaddy is designed around two steps:
|
|
16
|
+
|
|
17
|
+
1. Run a benchmark sweep over one or more configurations.
|
|
18
|
+
2. Inspect or compare the recorded results from the database (e.g. using the CLI).
|
|
19
|
+
|
|
20
|
+
This example stays self-contained and benchmarks a nonlinear iterative transform
|
|
21
|
+
with two variants and two input sizes.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import math
|
|
25
|
+
|
|
26
|
+
from benchcaddy import Sweep, observe
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def initial_signal(size: int) -> list[float]:
|
|
30
|
+
return [
|
|
31
|
+
math.sin(index * 0.013) + 0.5 * math.cos(index * 0.007)
|
|
32
|
+
for index in range(size)
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@observe("nonlinear_iteration")
|
|
37
|
+
def nonlinear_iteration(values: list[float], variant: str) -> list[float]:
|
|
38
|
+
next_values: list[float] = []
|
|
39
|
+
for value in values:
|
|
40
|
+
transformed = (
|
|
41
|
+
math.tanh(value * 1.4)
|
|
42
|
+
+ 0.75 * math.sin(value * value + 0.2)
|
|
43
|
+
+ 0.25 * math.cos(value - 0.1)
|
|
44
|
+
)
|
|
45
|
+
if variant == "stabilized":
|
|
46
|
+
transformed += 0.05 * value * value
|
|
47
|
+
else:
|
|
48
|
+
transformed += 0.03 * math.exp(-(value * value))
|
|
49
|
+
next_values.append(transformed)
|
|
50
|
+
return next_values
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def benchmark_case(size: int, variant: str) -> float:
|
|
54
|
+
values = initial_signal(size)
|
|
55
|
+
for _ in range(8):
|
|
56
|
+
values = nonlinear_iteration(values, variant)
|
|
57
|
+
return sum(abs(value) for value in values)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
Sweep(
|
|
61
|
+
target=benchmark_case,
|
|
62
|
+
params={
|
|
63
|
+
"size": [512, 2048],
|
|
64
|
+
"variant": ["baseline", "stabilized"],
|
|
65
|
+
},
|
|
66
|
+
suite_name="nonlinear-transform",
|
|
67
|
+
samples=5,
|
|
68
|
+
warmup_iterations=1,
|
|
69
|
+
verbose=True,
|
|
70
|
+
).run()
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
BenchCaddy writes samples, medians, observations, and environment metadata to
|
|
74
|
+
`benchcaddy.db` in the current working directory.
|
|
75
|
+
|
|
76
|
+
The full runnable example lives in the repository and source distribution at
|
|
77
|
+
[`examples/benchmark_nonlinear_transform.py`](https://github.com/MatthiasLen/BenchCaddy/blob/main/examples/benchmark_nonlinear_transform.py)
|
|
78
|
+
and supports `--verbose`, `--database`, `--samples`, and `--warmup-iterations`.
|
|
79
|
+
|
|
80
|
+
`Sweep` also accepts a script path as the target. In that mode, parameter keys
|
|
81
|
+
are mapped to CLI flags such as `size -> --size` and `warmup_runs` / `iterations`
|
|
82
|
+
can be used as aliases for `warmup_iterations` / `samples`.
|
|
83
|
+
|
|
84
|
+
## Sweep options
|
|
85
|
+
|
|
86
|
+
The main public `Sweep(...)` options are:
|
|
87
|
+
|
|
88
|
+
- `samples`: number of measured samples per configuration
|
|
89
|
+
- `iterations`: alias for `samples`
|
|
90
|
+
- `warmup_iterations`: warmup runs before sampling begins
|
|
91
|
+
- `warmup_runs`: alias for `warmup_iterations`
|
|
92
|
+
- `database_path`: store results in a specific SQLite file instead of `./benchcaddy.db`
|
|
93
|
+
- `lock_cpu_affinity`: preserve the current CPU affinity set before benchmarking
|
|
94
|
+
- `sync`: callable used to synchronize async device work after each invocation
|
|
95
|
+
- `reporter`: custom reporter implementing the `SweepReporter` protocol
|
|
96
|
+
- `verbose=True`: use the built-in Rich reporter during execution
|
|
97
|
+
|
|
98
|
+
## Script targets
|
|
99
|
+
|
|
100
|
+
You can benchmark a standalone script instead of a Python callable:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from benchcaddy import Sweep
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
Sweep(
|
|
107
|
+
target="./train_step.py",
|
|
108
|
+
params={
|
|
109
|
+
"size": [512, 2048],
|
|
110
|
+
"variant": ["baseline", "stabilized"],
|
|
111
|
+
"use_cache": [True, False],
|
|
112
|
+
},
|
|
113
|
+
suite_name="train-step",
|
|
114
|
+
samples=5,
|
|
115
|
+
).run()
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
BenchCaddy converts configuration keys to CLI flags:
|
|
119
|
+
|
|
120
|
+
- `size=512` becomes `--size 512`
|
|
121
|
+
- `use_cache=True` becomes `--use-cache`
|
|
122
|
+
- `use_cache=False` becomes `--use-cache false`
|
|
123
|
+
|
|
124
|
+
That mode works best with scripts that parse explicit values for non-presence
|
|
125
|
+
flags and exit with status code `0` on success.
|
|
126
|
+
|
|
127
|
+
## CLI and inspect results
|
|
128
|
+
|
|
129
|
+
List all recorded suites:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
benchcaddy list
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`list` also shows the observation labels seen across runs in each suite.
|
|
136
|
+
|
|
137
|
+
Show the recorded runs and environment for a suite:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
benchcaddy show nonlinear-transform
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Show the detailed timings for a single recorded run:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
benchcaddy show 12
|
|
147
|
+
benchcaddy show 2.3
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Composite run IDs use `SWEEP_ID.RUN_INDEX`, so `2.3` means the third run in
|
|
151
|
+
the second recorded sweep.
|
|
152
|
+
|
|
153
|
+
Show multiple runs side by side in a suite-style view:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
benchcaddy show 4 2.3 1.2
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Compare configurations within a suite by median runtime:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
benchcaddy compare nonlinear-transform
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Compare a suite against a selected recorded run instead of the best run:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
benchcaddy compare nonlinear-transform 2.4
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Restrict a suite comparison to runs that match selected configuration keys from
|
|
172
|
+
the reference run:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
benchcaddy compare nonlinear-transform 2.4 --strict size
|
|
176
|
+
benchcaddy compare nonlinear-transform 2.4 --strict size variant
|
|
177
|
+
benchcaddy compare nonlinear-transform 2.4 --strict variant
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Compare two specific runs directly. Improvements greater than 5% are shown in
|
|
181
|
+
green and regressions greater than 5% are shown in red:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
benchcaddy compare 12 15
|
|
185
|
+
benchcaddy compare 2.3 3
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
For more detail in the inspection output, add `--verbose`:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
benchcaddy --verbose show nonlinear-transform
|
|
192
|
+
benchcaddy --verbose compare nonlinear-transform
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## How to read the output
|
|
196
|
+
|
|
197
|
+
- `Mean +- Std (s)` is the arithmetic mean and sample standard deviation across benchmark samples
|
|
198
|
+
- suite comparisons are ranked by median runtime, not by the mean column
|
|
199
|
+
- `Best Median (s)`, `Delta vs Best`, and direct-run `Median Delta` / `Median Percent Change` all use median runtime
|
|
200
|
+
- observation tables report per-label timing aggregated across samples
|
|
201
|
+
- `Total (s)` in observation tables is the sum across all samples for that label
|
|
202
|
+
|
|
203
|
+
## Environment metadata
|
|
204
|
+
|
|
205
|
+
Every recorded run stores environment details alongside the timing data, including:
|
|
206
|
+
|
|
207
|
+
- Python version and operating system string
|
|
208
|
+
- CPU model and total system memory
|
|
209
|
+
- GPU model when it can be detected
|
|
210
|
+
- Git branch, commit hash, and dirty state when run inside a Git repository
|
|
211
|
+
- process metadata such as PID, priority, affinity, and RSS memory
|
|
Binary file
|