Skip to content

Commit 49c15d5

Browse files
committed
better benchmarks
1 parent 9eb1e6e commit 49c15d5

4 files changed

Lines changed: 285 additions & 402 deletions

File tree

.github/copilot-instructions.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Swift-BigInt
2+
3+
Swift 4.2 big number library (`BInt`, `BDouble`) with no external dependencies.
4+
5+
## Build & Test
6+
7+
```sh
8+
swift build # debug build
9+
swift test # run all tests
10+
just test-verify # release-mode correctness checks
11+
just test-full # same as swift test
12+
```
13+
14+
## Benchmarks
15+
16+
```sh
17+
just bench # run benchmarks, print results
18+
just bench-save # run benchmarks, save baseline to performance_baseline.json
19+
just bench-compare # run benchmarks, compare against saved baseline
20+
just bench 3 # run each benchmark 3 times, show per-run + average
21+
just bench-save 3 # save baseline averaged over 3 runs
22+
just bench-compare 3 # compare averages over 3 runs against baseline
23+
```
24+
25+
The `Benchmarks` binary accepts subcommands directly:
26+
- `Benchmarks [runs]` — print results
27+
- `Benchmarks save <file> [runs]` — save results as JSON
28+
- `Benchmarks compare <file> [runs]` — compare current run against JSON baseline
29+
30+
Benchmarks are defined declaratively in `Sources/Benchmarks/Benchmarks.swift` as a `[BenchmarkEntry]` array. Each entry has a name and a `setup` closure that returns the timed `body` closure. Setup work (allocations, precomputation) is not included in the measurement.
31+
32+
To add a benchmark, append a `BenchmarkEntry` to `allBenchmarks`. Then run `just bench-save` to update the baseline.

0 commit comments

Comments
 (0)