benchset 0.0.5__tar.gz → 0.0.6__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.
- {benchset-0.0.5 → benchset-0.0.6}/Cargo.lock +1 -1
- {benchset-0.0.5 → benchset-0.0.6}/Cargo.toml +1 -1
- {benchset-0.0.5 → benchset-0.0.6}/PKG-INFO +171 -17
- {benchset-0.0.5 → benchset-0.0.6}/Package.swift +2 -2
- {benchset-0.0.5 → benchset-0.0.6}/README.md +170 -16
- {benchset-0.0.5 → benchset-0.0.6}/Sources/Benchset/Benchset.swift +66 -1
- {benchset-0.0.5 → benchset-0.0.6}/benchset/__init__.py +2 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset/_native.py +4 -1
- {benchset-0.0.5 → benchset-0.0.6}/benchset/api.py +4 -3
- {benchset-0.0.5 → benchset-0.0.6}/benchset/cli.py +40 -27
- {benchset-0.0.5 → benchset-0.0.6}/benchset/models.py +33 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset.egg-info/PKG-INFO +171 -17
- {benchset-0.0.5 → benchset-0.0.6}/benchset.egg-info/SOURCES.txt +9 -0
- {benchset-0.0.5 → benchset-0.0.6}/include/benchset.h +31 -0
- {benchset-0.0.5 → benchset-0.0.6}/native/src/ffi.rs +10 -3
- {benchset-0.0.5 → benchset-0.0.6}/native/src/ffi_reference_tests.rs +29 -3
- {benchset-0.0.5 → benchset-0.0.6}/native/src/ffi_tests.rs +23 -0
- {benchset-0.0.5 → benchset-0.0.6}/native/src/lib.rs +81 -4
- {benchset-0.0.5 → benchset-0.0.6}/native/src/runtime_tests.rs +132 -45
- benchset-0.0.6/native/src/suite_ffi.rs +243 -0
- benchset-0.0.6/native/src/suite_ffi_tests.rs +477 -0
- benchset-0.0.6/native/src/suite_tests.rs +207 -0
- {benchset-0.0.5 → benchset-0.0.6}/pyproject.toml +1 -1
- {benchset-0.0.5 → benchset-0.0.6}/scripts/build_native.py +7 -1
- benchset-0.0.6/scripts/cargo.py +11 -0
- {benchset-0.0.5 → benchset-0.0.6}/scripts/check_source_install.py +19 -0
- {benchset-0.0.5 → benchset-0.0.6}/scripts/package_native.py +15 -5
- {benchset-0.0.5 → benchset-0.0.6}/scripts/release.py +5 -2
- {benchset-0.0.5 → benchset-0.0.6}/setup.py +9 -3
- {benchset-0.0.5 → benchset-0.0.6}/tests/swift/BenchsetTests.swift +342 -35
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_benchset.py +9 -1
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_build.py +31 -3
- benchset-0.0.6/tests/test_build_native.py +80 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_cli.py +160 -38
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_errors.py +1 -1
- benchset-0.0.6/tests/test_native_coverage.py +280 -0
- benchset-0.0.6/tests/test_packaging.py +188 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_reference.py +22 -6
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_reference_artifacts.py +353 -33
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_reference_native.py +2 -0
- benchset-0.0.6/tests/test_release.py +687 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_semantics.py +89 -12
- benchset-0.0.6/tests/test_setup.py +208 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_signals.py +7 -0
- benchset-0.0.6/tests/test_suite.py +179 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_version.py +28 -4
- {benchset-0.0.5 → benchset-0.0.6}/tests/typing/reference_positive.py +13 -2
- {benchset-0.0.5 → benchset-0.0.6}/tests/typing/test_reference_types.py +2 -0
- benchset-0.0.5/tests/test_release.py +0 -358
- {benchset-0.0.5 → benchset-0.0.6}/LICENSE +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/MANIFEST.in +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset/__main__.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset/py.typed +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset/reference.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset.egg-info/dependency_links.txt +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset.egg-info/entry_points.txt +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset.egg-info/requires.txt +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/benchset.egg-info/top_level.txt +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/examples/native/c.c +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/examples/native/rust.rs +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/examples/native/swift.swift +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/include/module.modulemap +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/native/reference-calibration.json +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/native/src/kernel.rs +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/native/src/kernel_tests.rs +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/native/src/reference.rs +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/native/src/reference_tests.rs +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/rust-toolchain.toml +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/scripts/__init__.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/scripts/build_backend.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/scripts/check_native_coverage.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/scripts/version.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/setup.cfg +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/__init__.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/helpers.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/swift/ReferenceTests.swift +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/test_resources.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/typing/__init__.py +0 -0
- {benchset-0.0.5 → benchset-0.0.6}/tests/typing/reference_negative.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: benchset
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Sustained scalar CPU benchmarks with an embeddable Rust core
|
|
5
5
|
Author-email: Evgeniy Blinov <zheni-b@yandex.ru>
|
|
6
6
|
Project-URL: Source, https://github.com/mutating/benchset
|
|
@@ -45,6 +45,10 @@ Higher is faster. Each completed result also includes a **Pi equivalent**:
|
|
|
45
45
|
its throughput divided by the same benchmark's sustained Raspberry Pi 5 score.
|
|
46
46
|
`0.5` means half the Pi's throughput, `1.0` equal throughput, and `2.0` twice
|
|
47
47
|
the Pi's throughput. The CLI prints both iterations/s and `Pi equivalent`.
|
|
48
|
+
The full suite also returns **aggregated scores**. Its **Full Pi equivalent** is
|
|
49
|
+
the geometric mean of the individual Pi equivalents, with equal weights.
|
|
50
|
+
See [Full-suite score](#full-suite-score) for the formula, availability rules
|
|
51
|
+
and the field to read in each interface.
|
|
48
52
|
|
|
49
53
|
This README describes the current source tree. For changes not yet published,
|
|
50
54
|
use `pip install .` or the local Rust/Swift dependencies described below.
|
|
@@ -95,8 +99,9 @@ suite stops after a failed or cancelled benchmark.
|
|
|
95
99
|
Each result is flushed immediately, including when stdout is redirected.
|
|
96
100
|
Progress fits the terminal width and is cleared before the result. Output
|
|
97
101
|
uses `× pi` and `—` when the stream supports them, with `x pi` and `-` as
|
|
98
|
-
fallbacks for restrictive encodings.
|
|
99
|
-
|
|
102
|
+
fallbacks for restrictive encodings. Streams configured with `backslashreplace`
|
|
103
|
+
may emit Unicode escape sequences instead. A closed stdout pipe exits with
|
|
104
|
+
code 1 without a traceback.
|
|
100
105
|
|
|
101
106
|
For example, a completed result at half the reference throughput includes
|
|
102
107
|
these lines (illustrative values; other fields and samples are omitted):
|
|
@@ -112,6 +117,60 @@ Pi equivalent : 0.5 × pi
|
|
|
112
117
|
The multiplier uses the full-precision native score, before display rounding.
|
|
113
118
|
An unavailable multiplier is displayed as `—` (`-` in the fallback format).
|
|
114
119
|
|
|
120
|
+
## Full-suite score
|
|
121
|
+
|
|
122
|
+
Run the complete suite to obtain its overall score:
|
|
123
|
+
|
|
124
|
+
| Interface | Run the suite | Read the Full Pi equivalent |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| CLI | `benchset` or `benchset --bench all` | Final `Full Pi equivalent` line |
|
|
127
|
+
| Python | `suite = run_all(...)` (module-level function) | `suite.aggregated_scores.pi_equivalent` |
|
|
128
|
+
| Rust | `let suite = benchset::run_all(options, &cancellation, callback);` | `suite.aggregated_scores.pi_equivalent` |
|
|
129
|
+
| Swift | `let suite = try runner.runAll(...)` | `suite.aggregatedScores.piEquivalent` |
|
|
130
|
+
| C / C++ | `benchset_run_all(...)`, then `benchset_suite_result(...)` | `suite.aggregated_scores.pi_equivalent` when `has_pi_equivalent != 0` |
|
|
131
|
+
|
|
132
|
+
For each benchmark, let `r = score / that_benchmark_reference_score`.
|
|
133
|
+
For positive ratios, the full score is `exp(sum(ln(r)) / benchmark_count)`.
|
|
134
|
+
With the current two benchmarks this is mathematically
|
|
135
|
+
`sqrt(r_single_core * r_multi_core)`. Each benchmark has equal weight,
|
|
136
|
+
independently of its worker count or measurement duration. The resulting
|
|
137
|
+
multiplier is dimensionless; individual `score` fields remain iterations/s.
|
|
138
|
+
|
|
139
|
+
The implementations use natural logarithms and `exp` on the original,
|
|
140
|
+
unrounded double-precision ratios. Log space avoids intermediate overflow or
|
|
141
|
+
underflow from multiplying ratios. Any consistent logarithm base and its
|
|
142
|
+
inverse give the same mathematical result; ordinary floating-point rounding
|
|
143
|
+
still applies. For example, `0.5` and `2.0` produce exactly `1.0`, and `1.0`
|
|
144
|
+
and `4.0` produce `2.0`. The first example's CLI summary is:
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
Full Pi equivalent : 1 × pi
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
A full score requires exactly `single_core` then `multi_core`, both with
|
|
151
|
+
`completed` status and a present, finite, nonnegative Pi equivalent. Completed
|
|
152
|
+
unstable results participate. After validating the complete set, any zero ratio
|
|
153
|
+
makes the full score `0.0`. Zero is a valid score: check `is not None` in Python,
|
|
154
|
+
`Some` in Rust, `if let` in Swift, or the presence flag in C.
|
|
155
|
+
|
|
156
|
+
An incomplete, failed or cancelled suite has no aggregate: `None` in
|
|
157
|
+
Python/Rust, `nil` in Swift, or a zero presence flag in C. When a benchmark
|
|
158
|
+
fails or is cancelled, a returned suite retains the completed prefix and the
|
|
159
|
+
first unsuccessful result. Results assembled by callers must also have the
|
|
160
|
+
complete order, without duplicates or
|
|
161
|
+
extra entries. Use `SuiteResult.from_results(tuple_of_results)` in Python,
|
|
162
|
+
`SuiteResult::new(results)` in Rust, or `SuiteResult(results: results)` in Swift
|
|
163
|
+
to calculate the aggregate from their stored individual Pi equivalents.
|
|
164
|
+
Python's direct `SuiteResult(results, aggregated_scores)` constructor stores
|
|
165
|
+
the supplied fields; it does not calculate an aggregate.
|
|
166
|
+
|
|
167
|
+
The CLI prints the summary on stdout after success or stderr after
|
|
168
|
+
failure/cancellation, using `—` (`-` in the fallback format) when unavailable.
|
|
169
|
+
An interrupted CLI call suppresses the aggregate even if its final native
|
|
170
|
+
result had already completed. Selecting only one benchmark prints no suite
|
|
171
|
+
summary. Progress fractions belong to the benchmark currently running and
|
|
172
|
+
restart for the next benchmark.
|
|
173
|
+
|
|
115
174
|
## Python API
|
|
116
175
|
|
|
117
176
|
Python 3.8–3.15, including free-threaded CPython, is supported. The wrapper uses
|
|
@@ -126,7 +185,15 @@ if result.success:
|
|
|
126
185
|
else:
|
|
127
186
|
print(result.status, result.reason)
|
|
128
187
|
|
|
129
|
-
|
|
188
|
+
suite = run_all(warmup_seconds=120, measurement_seconds=60)
|
|
189
|
+
results = suite.results # Tuple[BenchmarkResult, ...]
|
|
190
|
+
full_pi = suite.aggregated_scores.pi_equivalent
|
|
191
|
+
if full_pi is not None:
|
|
192
|
+
print(f'Full Pi equivalent: {full_pi} x pi')
|
|
193
|
+
else:
|
|
194
|
+
for item in results:
|
|
195
|
+
if not item.success:
|
|
196
|
+
print(item.benchmark, item.status, item.reason)
|
|
130
197
|
print(result.reference_run.started_at, result.reference_run.results)
|
|
131
198
|
```
|
|
132
199
|
|
|
@@ -149,12 +216,22 @@ with ThreadPoolExecutor(max_workers=1) as pool:
|
|
|
149
216
|
Callbacks execute on the thread calling `run`, approximately ten times per
|
|
150
217
|
second and on observed phase transitions. A very short phase can finish before
|
|
151
218
|
the coordinator reports it, so callback sequences may omit that phase.
|
|
152
|
-
Callbacks receive the benchmark name, phase,
|
|
219
|
+
Callbacks receive one `Progress` object containing the benchmark name, phase,
|
|
153
220
|
worker count, overall fraction, phase elapsed/target time and completed
|
|
154
221
|
iterations in that phase. Dispatch UI updates to the UI thread yourself and
|
|
155
222
|
return promptly. A Python callback exception cancels the workload and produces
|
|
156
223
|
a failed result; it does not propagate through C.
|
|
157
224
|
|
|
225
|
+
`run_all()` returns an immutable `SuiteResult`, with `results` (a tuple of
|
|
226
|
+
individual results in execution order) and `aggregated_scores: AggregatedScores`.
|
|
227
|
+
The current aggregate is `pi_equivalent: Optional[float]`; see
|
|
228
|
+
[Full-suite score](#full-suite-score) for its calculation and availability.
|
|
229
|
+
`dataclasses.asdict(suite)` produces `{"results": ..., "aggregated_scores":
|
|
230
|
+
{"pi_equivalent": ...}}`, including the individual results' nested calibration
|
|
231
|
+
records. `dataclasses.asdict(result)` also works for a single benchmark.
|
|
232
|
+
Consumers that previously iterated over `run_all()` directly should now iterate
|
|
233
|
+
over `run_all().results`.
|
|
234
|
+
|
|
158
235
|
`BenchmarkRunner.cancel()` is thread-safe and requests cancellation without
|
|
159
236
|
waiting for the active call to finish. After `run()` returns, all native workers
|
|
160
237
|
are joined and the runner can be reused. Concurrent
|
|
@@ -354,9 +431,12 @@ settings are comparable.
|
|
|
354
431
|
|
|
355
432
|
## Embed in Rust
|
|
356
433
|
|
|
434
|
+
Source consumers need Rust 1.74 or newer. Published native binaries use the
|
|
435
|
+
pinned release toolchain described under [Publishing](#publishing).
|
|
436
|
+
|
|
357
437
|
```toml
|
|
358
438
|
[dependencies]
|
|
359
|
-
benchset = "0.0.
|
|
439
|
+
benchset = "0.0.6"
|
|
360
440
|
# For changes from a local source checkout, use:
|
|
361
441
|
# benchset = { path = "../benchset" }
|
|
362
442
|
```
|
|
@@ -372,11 +452,23 @@ if let (Some(score), Some(equivalent)) = (result.score, result.pi_equivalent) {
|
|
|
372
452
|
println!("{:?}: {}", result.status, result.reason);
|
|
373
453
|
}
|
|
374
454
|
println!("Reference warmup: {} s", result.reference_run.warmup_seconds);
|
|
455
|
+
|
|
456
|
+
let suite_cancellation = Cancellation::default();
|
|
457
|
+
let suite = benchset::run_all(Options::default(), &suite_cancellation, |benchmark, progress| {
|
|
458
|
+
println!("{}: {}", benchmark.name(), progress.fraction);
|
|
459
|
+
});
|
|
460
|
+
if let Some(full_pi) = suite.aggregated_scores.pi_equivalent {
|
|
461
|
+
println!("Full Pi equivalent: {full_pi} x pi");
|
|
462
|
+
} else {
|
|
463
|
+
println!("Full Pi equivalent unavailable");
|
|
464
|
+
}
|
|
465
|
+
// suite.results contains the individual BenchmarkResult values in order.
|
|
375
466
|
```
|
|
376
467
|
|
|
377
|
-
The cancellation token can be cloned and cancelled from another thread.
|
|
378
|
-
|
|
379
|
-
|
|
468
|
+
The cancellation token can be cloned and cancelled from another thread. Once
|
|
469
|
+
cancelled, it stays cancelled; create a fresh token for a subsequent uncancelled
|
|
470
|
+
call. The suite uses the same token across both benchmarks. A short runnable
|
|
471
|
+
example is in `examples/native/rust.rs`.
|
|
380
472
|
|
|
381
473
|
## Embed through C ABI
|
|
382
474
|
|
|
@@ -422,6 +514,37 @@ string is valid for the loaded library's lifetime. Progress pointers are
|
|
|
422
514
|
borrowed only during the callback. Do not free a handle while it is in use or
|
|
423
515
|
throw/unwind through a C callback. Invalid configuration produces a failed result.
|
|
424
516
|
|
|
517
|
+
For a full suite, create a `BenchsetSuiteHandle` with `benchset_suite_create()`
|
|
518
|
+
and call `benchset_run_all(handle, &config, callback, context)`. The benchmark
|
|
519
|
+
selector is ignored; warmup and measurement settings apply to each benchmark.
|
|
520
|
+
The callback receives `BenchsetSuiteProgress`, containing the benchmark ID and
|
|
521
|
+
its progress. `benchset_run_all` returns the final individual result's status.
|
|
522
|
+
After the call, `benchset_suite_result(handle, &suite, sizeof(suite))`
|
|
523
|
+
fills a `BenchsetSuiteResult` with `results`, `result_count` and
|
|
524
|
+
`aggregated_scores`, returning 1 on success or 0 if the getter fails.
|
|
525
|
+
The immutable result array is borrowed until the handle is freed.
|
|
526
|
+
Check `suite.aggregated_scores.has_pi_equivalent` before reading its
|
|
527
|
+
`pi_equivalent` value. Read individual results with `benchset_suite_result_at`
|
|
528
|
+
(V3 format), and diagnostics with `benchset_suite_sample` and
|
|
529
|
+
`benchset_suite_reason`. Use `benchset_suite_cancel` and `benchset_suite_free`
|
|
530
|
+
for cancellation and cleanup. The same single-use and lifetime rules apply.
|
|
531
|
+
|
|
532
|
+
For example, using the initialized `config` above and no progress callback:
|
|
533
|
+
|
|
534
|
+
```c
|
|
535
|
+
BenchsetSuiteHandle *suite_handle = benchset_suite_create();
|
|
536
|
+
if (!suite_handle) return 1;
|
|
537
|
+
benchset_run_all(suite_handle, &config, NULL, NULL);
|
|
538
|
+
BenchsetSuiteResult suite;
|
|
539
|
+
if (benchset_suite_result(suite_handle, &suite, sizeof(suite)) &&
|
|
540
|
+
suite.aggregated_scores.has_pi_equivalent != 0) {
|
|
541
|
+
printf("Full Pi equivalent: %.12g x pi\n", suite.aggregated_scores.pi_equivalent);
|
|
542
|
+
} else {
|
|
543
|
+
printf("Full Pi equivalent unavailable\n");
|
|
544
|
+
}
|
|
545
|
+
benchset_suite_free(suite_handle);
|
|
546
|
+
```
|
|
547
|
+
|
|
425
548
|
The C ABI version remains 1. The additive, size-checked
|
|
426
549
|
`benchset_reference_machine`, `benchset_reference_run` and indexed
|
|
427
550
|
`benchset_reference_result` getters need no handle. Their
|
|
@@ -473,7 +596,7 @@ the same repository. Rust is not required by the consumer.
|
|
|
473
596
|
For a Swift manifest, add:
|
|
474
597
|
|
|
475
598
|
```swift
|
|
476
|
-
.package(url: "https://github.com/mutating/benchset.git", .exact("0.0.
|
|
599
|
+
.package(url: "https://github.com/mutating/benchset.git", .exact("0.0.6"))
|
|
477
600
|
```
|
|
478
601
|
|
|
479
602
|
Add `.product(name: "Benchset", package: "benchset")` to your target's
|
|
@@ -499,9 +622,24 @@ if let score = result.score, let equivalent = result.piEquivalent {
|
|
|
499
622
|
print(result.status, result.reason as Any)
|
|
500
623
|
}
|
|
501
624
|
print(result.referenceRun.startedAt, result.referenceRun.warmupSeconds)
|
|
502
|
-
|
|
625
|
+
let suite = try runner.runAll(warmupSeconds: 120, measurementSeconds: 60) { benchmark, progress in
|
|
626
|
+
print(benchmark, progress.fraction)
|
|
627
|
+
}
|
|
628
|
+
if let fullPi = suite.aggregatedScores.piEquivalent {
|
|
629
|
+
print("Full Pi equivalent: \(fullPi) x pi")
|
|
630
|
+
} else {
|
|
631
|
+
print("Full Pi equivalent unavailable")
|
|
632
|
+
}
|
|
633
|
+
// suite.results contains the individual BenchmarkResult values in order.
|
|
634
|
+
// Another thread may call runner.cancel() while run or runAll is active.
|
|
503
635
|
```
|
|
504
636
|
|
|
637
|
+
`runAll` keeps the runner reserved across both benchmarks; cancellation also
|
|
638
|
+
applies between its native handles. Native failure/cancellation returns the
|
|
639
|
+
results obtained so far with a `nil` aggregate. Wrapper errors such as allocation
|
|
640
|
+
failure or an unavailable native result throw `BenchsetError`; that call returns
|
|
641
|
+
no `SuiteResult`.
|
|
642
|
+
|
|
505
643
|
To build the Apple package from source:
|
|
506
644
|
|
|
507
645
|
```sh
|
|
@@ -530,15 +668,28 @@ are not part of the initial prebuilt matrix.
|
|
|
530
668
|
python -m venv .venv
|
|
531
669
|
# Activate the virtual environment using your shell's normal command.
|
|
532
670
|
pip install -r requirements_dev.txt 'skelet>=0.0.21' wheel setuptools
|
|
533
|
-
pip install .
|
|
534
|
-
python
|
|
535
|
-
python -m pytest
|
|
536
|
-
cargo test -- --test-threads=1
|
|
671
|
+
pip install -e .
|
|
672
|
+
python -m pytest tests
|
|
537
673
|
python -m build
|
|
674
|
+
# Native development commands additionally require Cargo on PATH:
|
|
675
|
+
python scripts/build_native.py
|
|
676
|
+
cargo test --locked -- --test-threads=1
|
|
538
677
|
```
|
|
539
678
|
|
|
540
|
-
|
|
541
|
-
|
|
679
|
+
The editable install builds the native library and installs Python dependencies
|
|
680
|
+
and package metadata. `scripts/build_native.py` rebuilds the library beside the
|
|
681
|
+
Python source; it requires Cargo on PATH and does not install Python package
|
|
682
|
+
metadata. Imports still need that metadata because the version is read through
|
|
683
|
+
`importlib.metadata`. After changing the package version, reinstall the Python
|
|
684
|
+
package so its metadata and native library agree. Python-only development can
|
|
685
|
+
use `pip install -e .` to build with the private Rust bootstrap; it does not put
|
|
686
|
+
Cargo on the shell's PATH for standalone native commands.
|
|
687
|
+
|
|
688
|
+
Build and native packaging commands honor `CARGO_TARGET_DIR`; relative paths
|
|
689
|
+
are resolved against the project directory. The frozen-crate verification uses
|
|
690
|
+
the same Cargo output directory.
|
|
691
|
+
|
|
692
|
+
Release wheels are platform-specific but interpreter-independent
|
|
542
693
|
(`py3-none-<platform>`). The sdist includes the native source. Tests validate
|
|
543
694
|
correctness, result accounting, progress, cancellation and API/CLI behavior;
|
|
544
695
|
they do not enforce speed thresholds in CI.
|
|
@@ -557,6 +708,9 @@ The [test matrix](tests/coverage-plan.md) combines five independent reviews and
|
|
|
557
708
|
covers measurement accounting, statistical boundaries, cancellation, reentry,
|
|
558
709
|
callback failures, C ABI validation, ownership and CLI behavior. Tests use
|
|
559
710
|
controlled initialization failures instead of exhausting machine resources.
|
|
711
|
+
Full-suite tests also cover complete ordering, geometric means of unrounded
|
|
712
|
+
ratios, zero/invalid/extreme values, early stopping, serialization and the
|
|
713
|
+
aggregate's presence in each public interface.
|
|
560
714
|
|
|
561
715
|
Python coverage includes statements and branches, including CLI subprocesses;
|
|
562
716
|
CI installs a coverage startup hook for those subprocesses. Rust and Swift each
|
|
@@ -9,8 +9,8 @@ let package = Package(
|
|
|
9
9
|
products: [.library(name: "Benchset", targets: ["Benchset"])],
|
|
10
10
|
targets: [
|
|
11
11
|
.binaryTarget(name: "CBenchset",
|
|
12
|
-
url: "https://github.com/mutating/benchset/releases/download/v0.0.
|
|
13
|
-
checksum: "
|
|
12
|
+
url: "https://github.com/mutating/benchset/releases/download/v0.0.6/Benchset.xcframework.zip",
|
|
13
|
+
checksum: "989e592027e5e5e072a2d7a1ebc7971f12d7e41b6ced25e6d0ea37ce8043602d"),
|
|
14
14
|
.target(name: "Benchset", dependencies: ["CBenchset"]),
|
|
15
15
|
.testTarget(name: "BenchsetTests", dependencies: ["Benchset"], path: "tests/swift")
|
|
16
16
|
]
|
|
@@ -11,6 +11,10 @@ Higher is faster. Each completed result also includes a **Pi equivalent**:
|
|
|
11
11
|
its throughput divided by the same benchmark's sustained Raspberry Pi 5 score.
|
|
12
12
|
`0.5` means half the Pi's throughput, `1.0` equal throughput, and `2.0` twice
|
|
13
13
|
the Pi's throughput. The CLI prints both iterations/s and `Pi equivalent`.
|
|
14
|
+
The full suite also returns **aggregated scores**. Its **Full Pi equivalent** is
|
|
15
|
+
the geometric mean of the individual Pi equivalents, with equal weights.
|
|
16
|
+
See [Full-suite score](#full-suite-score) for the formula, availability rules
|
|
17
|
+
and the field to read in each interface.
|
|
14
18
|
|
|
15
19
|
This README describes the current source tree. For changes not yet published,
|
|
16
20
|
use `pip install .` or the local Rust/Swift dependencies described below.
|
|
@@ -61,8 +65,9 @@ suite stops after a failed or cancelled benchmark.
|
|
|
61
65
|
Each result is flushed immediately, including when stdout is redirected.
|
|
62
66
|
Progress fits the terminal width and is cleared before the result. Output
|
|
63
67
|
uses `× pi` and `—` when the stream supports them, with `x pi` and `-` as
|
|
64
|
-
fallbacks for restrictive encodings.
|
|
65
|
-
|
|
68
|
+
fallbacks for restrictive encodings. Streams configured with `backslashreplace`
|
|
69
|
+
may emit Unicode escape sequences instead. A closed stdout pipe exits with
|
|
70
|
+
code 1 without a traceback.
|
|
66
71
|
|
|
67
72
|
For example, a completed result at half the reference throughput includes
|
|
68
73
|
these lines (illustrative values; other fields and samples are omitted):
|
|
@@ -78,6 +83,60 @@ Pi equivalent : 0.5 × pi
|
|
|
78
83
|
The multiplier uses the full-precision native score, before display rounding.
|
|
79
84
|
An unavailable multiplier is displayed as `—` (`-` in the fallback format).
|
|
80
85
|
|
|
86
|
+
## Full-suite score
|
|
87
|
+
|
|
88
|
+
Run the complete suite to obtain its overall score:
|
|
89
|
+
|
|
90
|
+
| Interface | Run the suite | Read the Full Pi equivalent |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| CLI | `benchset` or `benchset --bench all` | Final `Full Pi equivalent` line |
|
|
93
|
+
| Python | `suite = run_all(...)` (module-level function) | `suite.aggregated_scores.pi_equivalent` |
|
|
94
|
+
| Rust | `let suite = benchset::run_all(options, &cancellation, callback);` | `suite.aggregated_scores.pi_equivalent` |
|
|
95
|
+
| Swift | `let suite = try runner.runAll(...)` | `suite.aggregatedScores.piEquivalent` |
|
|
96
|
+
| C / C++ | `benchset_run_all(...)`, then `benchset_suite_result(...)` | `suite.aggregated_scores.pi_equivalent` when `has_pi_equivalent != 0` |
|
|
97
|
+
|
|
98
|
+
For each benchmark, let `r = score / that_benchmark_reference_score`.
|
|
99
|
+
For positive ratios, the full score is `exp(sum(ln(r)) / benchmark_count)`.
|
|
100
|
+
With the current two benchmarks this is mathematically
|
|
101
|
+
`sqrt(r_single_core * r_multi_core)`. Each benchmark has equal weight,
|
|
102
|
+
independently of its worker count or measurement duration. The resulting
|
|
103
|
+
multiplier is dimensionless; individual `score` fields remain iterations/s.
|
|
104
|
+
|
|
105
|
+
The implementations use natural logarithms and `exp` on the original,
|
|
106
|
+
unrounded double-precision ratios. Log space avoids intermediate overflow or
|
|
107
|
+
underflow from multiplying ratios. Any consistent logarithm base and its
|
|
108
|
+
inverse give the same mathematical result; ordinary floating-point rounding
|
|
109
|
+
still applies. For example, `0.5` and `2.0` produce exactly `1.0`, and `1.0`
|
|
110
|
+
and `4.0` produce `2.0`. The first example's CLI summary is:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
Full Pi equivalent : 1 × pi
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
A full score requires exactly `single_core` then `multi_core`, both with
|
|
117
|
+
`completed` status and a present, finite, nonnegative Pi equivalent. Completed
|
|
118
|
+
unstable results participate. After validating the complete set, any zero ratio
|
|
119
|
+
makes the full score `0.0`. Zero is a valid score: check `is not None` in Python,
|
|
120
|
+
`Some` in Rust, `if let` in Swift, or the presence flag in C.
|
|
121
|
+
|
|
122
|
+
An incomplete, failed or cancelled suite has no aggregate: `None` in
|
|
123
|
+
Python/Rust, `nil` in Swift, or a zero presence flag in C. When a benchmark
|
|
124
|
+
fails or is cancelled, a returned suite retains the completed prefix and the
|
|
125
|
+
first unsuccessful result. Results assembled by callers must also have the
|
|
126
|
+
complete order, without duplicates or
|
|
127
|
+
extra entries. Use `SuiteResult.from_results(tuple_of_results)` in Python,
|
|
128
|
+
`SuiteResult::new(results)` in Rust, or `SuiteResult(results: results)` in Swift
|
|
129
|
+
to calculate the aggregate from their stored individual Pi equivalents.
|
|
130
|
+
Python's direct `SuiteResult(results, aggregated_scores)` constructor stores
|
|
131
|
+
the supplied fields; it does not calculate an aggregate.
|
|
132
|
+
|
|
133
|
+
The CLI prints the summary on stdout after success or stderr after
|
|
134
|
+
failure/cancellation, using `—` (`-` in the fallback format) when unavailable.
|
|
135
|
+
An interrupted CLI call suppresses the aggregate even if its final native
|
|
136
|
+
result had already completed. Selecting only one benchmark prints no suite
|
|
137
|
+
summary. Progress fractions belong to the benchmark currently running and
|
|
138
|
+
restart for the next benchmark.
|
|
139
|
+
|
|
81
140
|
## Python API
|
|
82
141
|
|
|
83
142
|
Python 3.8–3.15, including free-threaded CPython, is supported. The wrapper uses
|
|
@@ -92,7 +151,15 @@ if result.success:
|
|
|
92
151
|
else:
|
|
93
152
|
print(result.status, result.reason)
|
|
94
153
|
|
|
95
|
-
|
|
154
|
+
suite = run_all(warmup_seconds=120, measurement_seconds=60)
|
|
155
|
+
results = suite.results # Tuple[BenchmarkResult, ...]
|
|
156
|
+
full_pi = suite.aggregated_scores.pi_equivalent
|
|
157
|
+
if full_pi is not None:
|
|
158
|
+
print(f'Full Pi equivalent: {full_pi} x pi')
|
|
159
|
+
else:
|
|
160
|
+
for item in results:
|
|
161
|
+
if not item.success:
|
|
162
|
+
print(item.benchmark, item.status, item.reason)
|
|
96
163
|
print(result.reference_run.started_at, result.reference_run.results)
|
|
97
164
|
```
|
|
98
165
|
|
|
@@ -115,12 +182,22 @@ with ThreadPoolExecutor(max_workers=1) as pool:
|
|
|
115
182
|
Callbacks execute on the thread calling `run`, approximately ten times per
|
|
116
183
|
second and on observed phase transitions. A very short phase can finish before
|
|
117
184
|
the coordinator reports it, so callback sequences may omit that phase.
|
|
118
|
-
Callbacks receive the benchmark name, phase,
|
|
185
|
+
Callbacks receive one `Progress` object containing the benchmark name, phase,
|
|
119
186
|
worker count, overall fraction, phase elapsed/target time and completed
|
|
120
187
|
iterations in that phase. Dispatch UI updates to the UI thread yourself and
|
|
121
188
|
return promptly. A Python callback exception cancels the workload and produces
|
|
122
189
|
a failed result; it does not propagate through C.
|
|
123
190
|
|
|
191
|
+
`run_all()` returns an immutable `SuiteResult`, with `results` (a tuple of
|
|
192
|
+
individual results in execution order) and `aggregated_scores: AggregatedScores`.
|
|
193
|
+
The current aggregate is `pi_equivalent: Optional[float]`; see
|
|
194
|
+
[Full-suite score](#full-suite-score) for its calculation and availability.
|
|
195
|
+
`dataclasses.asdict(suite)` produces `{"results": ..., "aggregated_scores":
|
|
196
|
+
{"pi_equivalent": ...}}`, including the individual results' nested calibration
|
|
197
|
+
records. `dataclasses.asdict(result)` also works for a single benchmark.
|
|
198
|
+
Consumers that previously iterated over `run_all()` directly should now iterate
|
|
199
|
+
over `run_all().results`.
|
|
200
|
+
|
|
124
201
|
`BenchmarkRunner.cancel()` is thread-safe and requests cancellation without
|
|
125
202
|
waiting for the active call to finish. After `run()` returns, all native workers
|
|
126
203
|
are joined and the runner can be reused. Concurrent
|
|
@@ -320,9 +397,12 @@ settings are comparable.
|
|
|
320
397
|
|
|
321
398
|
## Embed in Rust
|
|
322
399
|
|
|
400
|
+
Source consumers need Rust 1.74 or newer. Published native binaries use the
|
|
401
|
+
pinned release toolchain described under [Publishing](#publishing).
|
|
402
|
+
|
|
323
403
|
```toml
|
|
324
404
|
[dependencies]
|
|
325
|
-
benchset = "0.0.
|
|
405
|
+
benchset = "0.0.6"
|
|
326
406
|
# For changes from a local source checkout, use:
|
|
327
407
|
# benchset = { path = "../benchset" }
|
|
328
408
|
```
|
|
@@ -338,11 +418,23 @@ if let (Some(score), Some(equivalent)) = (result.score, result.pi_equivalent) {
|
|
|
338
418
|
println!("{:?}: {}", result.status, result.reason);
|
|
339
419
|
}
|
|
340
420
|
println!("Reference warmup: {} s", result.reference_run.warmup_seconds);
|
|
421
|
+
|
|
422
|
+
let suite_cancellation = Cancellation::default();
|
|
423
|
+
let suite = benchset::run_all(Options::default(), &suite_cancellation, |benchmark, progress| {
|
|
424
|
+
println!("{}: {}", benchmark.name(), progress.fraction);
|
|
425
|
+
});
|
|
426
|
+
if let Some(full_pi) = suite.aggregated_scores.pi_equivalent {
|
|
427
|
+
println!("Full Pi equivalent: {full_pi} x pi");
|
|
428
|
+
} else {
|
|
429
|
+
println!("Full Pi equivalent unavailable");
|
|
430
|
+
}
|
|
431
|
+
// suite.results contains the individual BenchmarkResult values in order.
|
|
341
432
|
```
|
|
342
433
|
|
|
343
|
-
The cancellation token can be cloned and cancelled from another thread.
|
|
344
|
-
|
|
345
|
-
|
|
434
|
+
The cancellation token can be cloned and cancelled from another thread. Once
|
|
435
|
+
cancelled, it stays cancelled; create a fresh token for a subsequent uncancelled
|
|
436
|
+
call. The suite uses the same token across both benchmarks. A short runnable
|
|
437
|
+
example is in `examples/native/rust.rs`.
|
|
346
438
|
|
|
347
439
|
## Embed through C ABI
|
|
348
440
|
|
|
@@ -388,6 +480,37 @@ string is valid for the loaded library's lifetime. Progress pointers are
|
|
|
388
480
|
borrowed only during the callback. Do not free a handle while it is in use or
|
|
389
481
|
throw/unwind through a C callback. Invalid configuration produces a failed result.
|
|
390
482
|
|
|
483
|
+
For a full suite, create a `BenchsetSuiteHandle` with `benchset_suite_create()`
|
|
484
|
+
and call `benchset_run_all(handle, &config, callback, context)`. The benchmark
|
|
485
|
+
selector is ignored; warmup and measurement settings apply to each benchmark.
|
|
486
|
+
The callback receives `BenchsetSuiteProgress`, containing the benchmark ID and
|
|
487
|
+
its progress. `benchset_run_all` returns the final individual result's status.
|
|
488
|
+
After the call, `benchset_suite_result(handle, &suite, sizeof(suite))`
|
|
489
|
+
fills a `BenchsetSuiteResult` with `results`, `result_count` and
|
|
490
|
+
`aggregated_scores`, returning 1 on success or 0 if the getter fails.
|
|
491
|
+
The immutable result array is borrowed until the handle is freed.
|
|
492
|
+
Check `suite.aggregated_scores.has_pi_equivalent` before reading its
|
|
493
|
+
`pi_equivalent` value. Read individual results with `benchset_suite_result_at`
|
|
494
|
+
(V3 format), and diagnostics with `benchset_suite_sample` and
|
|
495
|
+
`benchset_suite_reason`. Use `benchset_suite_cancel` and `benchset_suite_free`
|
|
496
|
+
for cancellation and cleanup. The same single-use and lifetime rules apply.
|
|
497
|
+
|
|
498
|
+
For example, using the initialized `config` above and no progress callback:
|
|
499
|
+
|
|
500
|
+
```c
|
|
501
|
+
BenchsetSuiteHandle *suite_handle = benchset_suite_create();
|
|
502
|
+
if (!suite_handle) return 1;
|
|
503
|
+
benchset_run_all(suite_handle, &config, NULL, NULL);
|
|
504
|
+
BenchsetSuiteResult suite;
|
|
505
|
+
if (benchset_suite_result(suite_handle, &suite, sizeof(suite)) &&
|
|
506
|
+
suite.aggregated_scores.has_pi_equivalent != 0) {
|
|
507
|
+
printf("Full Pi equivalent: %.12g x pi\n", suite.aggregated_scores.pi_equivalent);
|
|
508
|
+
} else {
|
|
509
|
+
printf("Full Pi equivalent unavailable\n");
|
|
510
|
+
}
|
|
511
|
+
benchset_suite_free(suite_handle);
|
|
512
|
+
```
|
|
513
|
+
|
|
391
514
|
The C ABI version remains 1. The additive, size-checked
|
|
392
515
|
`benchset_reference_machine`, `benchset_reference_run` and indexed
|
|
393
516
|
`benchset_reference_result` getters need no handle. Their
|
|
@@ -439,7 +562,7 @@ the same repository. Rust is not required by the consumer.
|
|
|
439
562
|
For a Swift manifest, add:
|
|
440
563
|
|
|
441
564
|
```swift
|
|
442
|
-
.package(url: "https://github.com/mutating/benchset.git", .exact("0.0.
|
|
565
|
+
.package(url: "https://github.com/mutating/benchset.git", .exact("0.0.6"))
|
|
443
566
|
```
|
|
444
567
|
|
|
445
568
|
Add `.product(name: "Benchset", package: "benchset")` to your target's
|
|
@@ -465,9 +588,24 @@ if let score = result.score, let equivalent = result.piEquivalent {
|
|
|
465
588
|
print(result.status, result.reason as Any)
|
|
466
589
|
}
|
|
467
590
|
print(result.referenceRun.startedAt, result.referenceRun.warmupSeconds)
|
|
468
|
-
|
|
591
|
+
let suite = try runner.runAll(warmupSeconds: 120, measurementSeconds: 60) { benchmark, progress in
|
|
592
|
+
print(benchmark, progress.fraction)
|
|
593
|
+
}
|
|
594
|
+
if let fullPi = suite.aggregatedScores.piEquivalent {
|
|
595
|
+
print("Full Pi equivalent: \(fullPi) x pi")
|
|
596
|
+
} else {
|
|
597
|
+
print("Full Pi equivalent unavailable")
|
|
598
|
+
}
|
|
599
|
+
// suite.results contains the individual BenchmarkResult values in order.
|
|
600
|
+
// Another thread may call runner.cancel() while run or runAll is active.
|
|
469
601
|
```
|
|
470
602
|
|
|
603
|
+
`runAll` keeps the runner reserved across both benchmarks; cancellation also
|
|
604
|
+
applies between its native handles. Native failure/cancellation returns the
|
|
605
|
+
results obtained so far with a `nil` aggregate. Wrapper errors such as allocation
|
|
606
|
+
failure or an unavailable native result throw `BenchsetError`; that call returns
|
|
607
|
+
no `SuiteResult`.
|
|
608
|
+
|
|
471
609
|
To build the Apple package from source:
|
|
472
610
|
|
|
473
611
|
```sh
|
|
@@ -496,15 +634,28 @@ are not part of the initial prebuilt matrix.
|
|
|
496
634
|
python -m venv .venv
|
|
497
635
|
# Activate the virtual environment using your shell's normal command.
|
|
498
636
|
pip install -r requirements_dev.txt 'skelet>=0.0.21' wheel setuptools
|
|
499
|
-
pip install .
|
|
500
|
-
python
|
|
501
|
-
python -m pytest
|
|
502
|
-
cargo test -- --test-threads=1
|
|
637
|
+
pip install -e .
|
|
638
|
+
python -m pytest tests
|
|
503
639
|
python -m build
|
|
640
|
+
# Native development commands additionally require Cargo on PATH:
|
|
641
|
+
python scripts/build_native.py
|
|
642
|
+
cargo test --locked -- --test-threads=1
|
|
504
643
|
```
|
|
505
644
|
|
|
506
|
-
|
|
507
|
-
|
|
645
|
+
The editable install builds the native library and installs Python dependencies
|
|
646
|
+
and package metadata. `scripts/build_native.py` rebuilds the library beside the
|
|
647
|
+
Python source; it requires Cargo on PATH and does not install Python package
|
|
648
|
+
metadata. Imports still need that metadata because the version is read through
|
|
649
|
+
`importlib.metadata`. After changing the package version, reinstall the Python
|
|
650
|
+
package so its metadata and native library agree. Python-only development can
|
|
651
|
+
use `pip install -e .` to build with the private Rust bootstrap; it does not put
|
|
652
|
+
Cargo on the shell's PATH for standalone native commands.
|
|
653
|
+
|
|
654
|
+
Build and native packaging commands honor `CARGO_TARGET_DIR`; relative paths
|
|
655
|
+
are resolved against the project directory. The frozen-crate verification uses
|
|
656
|
+
the same Cargo output directory.
|
|
657
|
+
|
|
658
|
+
Release wheels are platform-specific but interpreter-independent
|
|
508
659
|
(`py3-none-<platform>`). The sdist includes the native source. Tests validate
|
|
509
660
|
correctness, result accounting, progress, cancellation and API/CLI behavior;
|
|
510
661
|
they do not enforce speed thresholds in CI.
|
|
@@ -523,6 +674,9 @@ The [test matrix](tests/coverage-plan.md) combines five independent reviews and
|
|
|
523
674
|
covers measurement accounting, statistical boundaries, cancellation, reentry,
|
|
524
675
|
callback failures, C ABI validation, ownership and CLI behavior. Tests use
|
|
525
676
|
controlled initialization failures instead of exhausting machine resources.
|
|
677
|
+
Full-suite tests also cover complete ordering, geometric means of unrounded
|
|
678
|
+
ratios, zero/invalid/extreme values, early stopping, serialization and the
|
|
679
|
+
aggregate's presence in each public interface.
|
|
526
680
|
|
|
527
681
|
Python coverage includes statements and branches, including CLI subprocesses;
|
|
528
682
|
CI installs a coverage startup hook for those subprocesses. Rust and Swift each
|