Skip to content

Commit 936fdb7

Browse files
committed
docs(ccusage): update native performance benchmark
Record the latest daily JSON measurements for both default auto mode and offline mode after adding native pricing fallback and terminal output parity.
1 parent b4b933d commit 936fdb7

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

‎apps/ccusage/RUST_REWRITE_BENCHMARK.md‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Measured on 2026-05-11 on macOS arm64 against the local Claude usage dataset.
77
```sh
88
target/release/ccusage daily --json --offline > /tmp/ccusage-rs-bench.json
99
bun -e 'process.argv = [process.argv[0], "ccusage", ...process.argv.slice(1)]; import("./apps/ccusage/src/commands/index.ts").then(m => m.run())' daily --json --offline > /tmp/ccusage-ts-bench.json
10+
target/release/ccusage daily --json > /tmp/ccusage-rs-auto-bench.json
11+
bun -e 'process.argv = [process.argv[0], "ccusage", ...process.argv.slice(1)]; import("./apps/ccusage/src/commands/index.ts").then(m => m.run())' daily --json > /tmp/ccusage-ts-auto-bench.json
1012
```
1113

1214
Benchmark command:
@@ -17,21 +19,40 @@ Benchmark command:
1719
"bun -e 'process.argv = [process.argv[0], \"ccusage\", ...process.argv.slice(1)]; import(\"./apps/ccusage/src/commands/index.ts\").then(m => m.run())' daily --json --offline > /tmp/ccusage-ts-bench.json"
1820
```
1921

22+
Default auto mode benchmark command:
23+
24+
```sh
25+
, hyperfine --warmup 1 --runs 5 \
26+
"target/release/ccusage daily --json > /tmp/ccusage-rs-auto-bench.json" \
27+
"bun -e 'process.argv = [process.argv[0], \"ccusage\", ...process.argv.slice(1)]; import(\"./apps/ccusage/src/commands/index.ts\").then(m => m.run())' daily --json > /tmp/ccusage-ts-auto-bench.json"
28+
```
29+
2030
## Results
2131

32+
### Offline Mode
33+
34+
| Implementation | Mean | Range | Notes |
35+
| ------------------- | -----------------: | ---------------: | ---------------------------- |
36+
| Rust release binary | 1.568s +/- 0.072s | 1.491s..1.683s | `target/release/ccusage` |
37+
| TypeScript via Bun | 11.487s +/- 1.611s | 10.593s..14.359s | direct command module import |
38+
39+
Rust was 7.33x +/- 1.08x faster for `daily --json --offline`.
40+
41+
### Default Auto Mode
42+
2243
| Implementation | Mean | Range | Notes |
2344
| ------------------- | -----------------: | ---------------: | ---------------------------- |
24-
| Rust release binary | 1.242s +/- 0.040s | 1.201s..1.286s | `target/release/ccusage` |
25-
| TypeScript via Bun | 10.749s +/- 0.665s | 10.237s..11.867s | direct command module import |
45+
| Rust release binary | 1.599s +/- 0.066s | 1.540s..1.699s | `target/release/ccusage` |
46+
| TypeScript via Bun | 11.648s +/- 1.088s | 10.757s..13.518s | direct command module import |
2647

27-
Rust was 8.65x +/- 0.60x faster for `daily --json --offline`.
48+
Rust was 7.29x +/- 0.74x faster for `daily --json`.
2849

2950
## Binary Size
3051

31-
`target/release/ccusage` is 2.0 MB (`du`: 2.0 MB) with release settings optimized for size (`opt-level = "z"`, fat LTO, single codegen unit, stripped symbols, abort panics).
52+
`target/release/ccusage` is 3.3 MB (`du`: 3.3 MB) with release settings optimized for size (`opt-level = "z"`, fat LTO, single codegen unit, stripped symbols, abort panics).
3253

3354
## Output Check
3455

3556
The benchmark output was compared against the TypeScript command path on the same live dataset with `jq -S` canonicalization.
3657

37-
The Rust and TypeScript JSON outputs were identical for `daily --json --offline`.
58+
The Rust and TypeScript JSON outputs were identical for `daily --json --offline` and `daily --json`.

0 commit comments

Comments
 (0)