Skip to content

Commit 78594af

Browse files
committed
refactor(bench): stabilize benchmark throughput tool
1 parent b92e7e2 commit 78594af

File tree

5 files changed

+82
-218
lines changed

5 files changed

+82
-218
lines changed

.github/workflows/bench-command.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,15 @@ jobs:
336336
echo "Checking out $BASELINE_REF..."
337337
git checkout "$BASELINE_REF"
338338
339-
# Check if bench_throughput binary is defined in Cargo.toml
340-
if ! grep -q 'name = "bench_throughput"' Cargo.toml 2>/dev/null; then
339+
# Check if bench-throughput binary is defined in Cargo.toml
340+
if ! grep -q 'name = "bench-throughput"' Cargo.toml 2>/dev/null; then
341341
echo "exists=false" >> $GITHUB_OUTPUT
342-
echo "❌ Benchmark tool 'bench_throughput' not found in $BASELINE_REF"
342+
echo "❌ Benchmark tool 'bench-throughput' not found in $BASELINE_REF"
343343
exit 0
344344
fi
345345
346346
# Check if the source file exists
347-
if ! grep -A 2 'name = "bench_throughput"' Cargo.toml | grep -q 'path.*='; then
347+
if ! grep -A 2 'name = "bench-throughput"' Cargo.toml | grep -q 'path.*='; then
348348
echo "exists=false" >> $GITHUB_OUTPUT
349349
echo "❌ Benchmark tool source file not found in $BASELINE_REF"
350350
exit 0
@@ -362,15 +362,15 @@ jobs:
362362
echo "Checking out $CURRENT_REF..."
363363
git checkout "$CURRENT_REF"
364364
365-
# Check if bench_throughput binary is defined in Cargo.toml
366-
if ! grep -q 'name = "bench_throughput"' Cargo.toml 2>/dev/null; then
365+
# Check if bench-throughput binary is defined in Cargo.toml
366+
if ! grep -q 'name = "bench-throughput"' Cargo.toml 2>/dev/null; then
367367
echo "exists=false" >> $GITHUB_OUTPUT
368-
echo "❌ Benchmark tool 'bench_throughput' not found in $CURRENT_REF"
368+
echo "❌ Benchmark tool 'bench-throughput' not found in $CURRENT_REF"
369369
exit 0
370370
fi
371371
372372
# Check if the source file exists
373-
if ! grep -A 2 'name = "bench_throughput"' Cargo.toml | grep -q 'path.*='; then
373+
if ! grep -A 2 'name = "bench-throughput"' Cargo.toml | grep -q 'path.*='; then
374374
echo "exists=false" >> $GITHUB_OUTPUT
375375
echo "❌ Benchmark tool source file not found in $CURRENT_REF"
376376
exit 0
@@ -390,7 +390,7 @@ jobs:
390390
const current_exists = '${{ steps.check_current_tool.outputs.exists }}' === 'true';
391391
392392
let message = '❌ **Benchmark comparison failed**\n\n';
393-
message += '**Reason**: The benchmark tool (`bench_throughput`) does not exist in ';
393+
message += '**Reason**: The benchmark tool (`bench-throughput`) does not exist in ';
394394
395395
if (!baseline_exists && !current_exists) {
396396
message += `both refs:\n- \`${baseline_ref}\` (baseline/older)\n- \`${current_ref}\` (current/newer)`;
@@ -429,16 +429,15 @@ jobs:
429429
git checkout "$BASELINE_REF"
430430
431431
echo "Building benchmark tool..."
432-
if ! cargo build --release --bin bench_throughput 2>&1 | tee build_baseline.log; then
432+
if ! cargo build --release --bin bench-throughput 2>&1 | tee build_baseline.log; then
433433
echo "❌ Failed to build benchmark tool for $BASELINE_REF"
434434
exit 1
435435
fi
436436
437437
echo "Running benchmarks on baseline..."
438-
./target/release/bench_throughput \
438+
./target/release/bench-throughput \
439439
--sizes "$SIZES" \
440440
--iterations "$ITERATIONS" \
441-
--format json \
442441
--output benchmark_baseline.json
443442
444443
- name: Benchmark current (newer commit)
@@ -454,16 +453,15 @@ jobs:
454453
455454
# Rebuild in case dependencies changed
456455
echo "Building benchmark tool..."
457-
if ! cargo build --release --bin bench_throughput 2>&1 | tee build_current.log; then
456+
if ! cargo build --release --bin bench-throughput 2>&1 | tee build_current.log; then
458457
echo "❌ Failed to build benchmark tool for $CURRENT_REF"
459458
exit 1
460459
fi
461460
462461
echo "Running benchmarks on current..."
463-
./target/release/bench_throughput \
462+
./target/release/bench-throughput \
464463
--sizes "$SIZES" \
465464
--iterations "$ITERATIONS" \
466-
--format json \
467465
--output benchmark_current.json
468466
469467
- name: Compare results

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ path = "src/bin/bench.rs"
4545

4646
[[bin]]
4747
bench = false
48-
name = "bench_throughput"
49-
path = "src/bin/bench_throughput.rs"
48+
name = "bench-throughput"
49+
path = "src/bin/bench-throughput.rs"
5050

5151
[profile.staging]
5252
inherits = "dev"

docs/benchmarking.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,38 @@ String Pipeline includes a throughput-based benchmarking tool for measuring perf
66

77
```bash
88
# Run with default settings
9-
cargo run --release --bin bench_throughput
9+
cargo run --release --bin bench-throughput
1010

1111
# Specify input sizes and iterations
12-
cargo run --release --bin bench_throughput -- --sizes 1000,5000,10000 --iterations 100
12+
cargo run --release --bin bench-throughput -- --sizes 1000,5000,10000 --iterations 100
1313

14-
# Generate JSON output for comparison
15-
cargo run --release --bin bench_throughput -- --format json --output results.json
14+
# Generate JSON output to custom location
15+
cargo run --release --bin bench-throughput -- --output results.json
1616

1717
# Verbose mode shows per-template details
18-
cargo run --release --bin bench_throughput -- --verbose
18+
cargo run --release --bin bench-throughput -- --verbose
1919
```
2020

2121
## Command Line Options
2222

2323
| Option | Short | Default | Description |
2424
|--------|-------|---------|-------------|
25-
| `--sizes` | `-s` | `100,500,1000,5000,10000,50000,100000` | Comma-separated input sizes |
26-
| `--iterations` | `-i` | `50` | Number of iterations per size |
27-
| `--format` | `-f` | `console` | Output format: `console` or `json` |
28-
| `--output` | `-o` | - | Output file path (for JSON format) |
25+
| `--sizes` | `-s` | `10000` | Comma-separated input sizes |
26+
| `--iterations` | `-i` | `1` | Number of iterations per size |
27+
| `--output` | `-o` | `$XDG_DATA_HOME/string-pipeline/benchmarks/bench-<timestamp>.json` | Override default JSON output location |
2928
| `--verbose` | `-v` | false | Show detailed per-template results |
3029

3130
## Methodology
3231

3332
The benchmark tool measures batch processing performance:
3433

3534
1. **Parse Phase**: Template is parsed once and timed across multiple iterations
36-
2. **Warmup**: Each input size runs once without timing to stabilize caches
35+
2. **Warmup**: Each input size runs once without timing to stabilize caches (skipped when iterations = 1)
3736
3. **Measurement**: Multiple iterations are timed to calculate statistics
3837
4. **Analysis**: Results include average, percentiles (p50, p95, p99), and standard deviation
3938

39+
The tool always outputs both a human-readable console report and JSON data for tracking over time.
40+
4041
### Test Data
4142

4243
The benchmark generates realistic absolute file paths with varying depths (2-10 levels) using common directory names,
@@ -69,12 +70,12 @@ Use the included Python script to compare two benchmark runs:
6970

7071
```bash
7172
# Run baseline benchmark
72-
cargo run --release --bin bench_throughput -- --format json --output baseline.json
73+
cargo run --release --bin bench-throughput -- --output baseline.json
7374

7475
# Make changes to the code
7576

7677
# Run current benchmark
77-
cargo run --release --bin bench_throughput -- --format json --output current.json
78+
cargo run --release --bin bench-throughput -- --output current.json
7879

7980
# Compare results
8081
python3 scripts/compare_benchmarks.py baseline.json current.json

0 commit comments

Comments
 (0)