bench: race busybox again, verify the wc oracle, average the speedup

Busybox wc is back in every suite, for shits and giggles. checkwc now
walks PATH and identifies each wc by its --version answer (coreutils and
fastwc respond; busybox names itself in the error it prints), so a wc
symlinked to fastwc is detected and skipped instead of silently racing
us against ourselves, and a missing coreutils is a clear configure
error. Every run now ends with the average speedup of fastwc against
coreutils and busybox, computed from the per-case ratios.

The fail-fast verdict now requires a measurable (>0ms) reference time,
so sub-millisecond cases stop flaking on startup noise, and the 100M
line monster is pinned back to the coreutils oracle instead of whatever
oracle was raced last.
This commit is contained in:
2026-08-29 21:50:50 -04:00
parent 7ab7efc7b9
commit 7a8b763416
6 changed files with 220 additions and 74 deletions
+25 -21
View File
@@ -2,9 +2,10 @@
# bench.sh — race fastwc against GNU coreutils wc on standard input, fed by
# shell redirect (the same path every real pipeline uses). Counts must agree
# with coreutils' stdin behavior, and fastwc must not be slower.
# Fails fast: the moment fastwc is slower than (or disagrees with) coreutils
# wc, a human readable report is written to FAILED-benchmark.txt and this
# script exits non-zero.
# Busybox wc is raced too, for shits and giggles.
# Fails fast: the moment fastwc is slower than (or disagrees with) an
# oracle wc, a human readable report is written to FAILED-benchmark.txt
# and this script exits non-zero.
#
# usage: ./bench.sh
set -u
@@ -15,26 +16,29 @@ source "$REPO_DIR/benchmarks/std.sh"
checkfastwc
checkwc
BENCH_NAME="coreutils"
printf 'benchmarking %s wc vs fastwc: stdin (%s interleaved runs each, minimum kept)\n' \
"$BENCH_NAME" "$BENCH_REPS"
printf '%-28s %10s %22s %8s %s\n' 'test' 'wc' 'fastwc (ms µs)' 'ratio' 'status'
for oracle in $ORACLES; do
select_oracle "$oracle" || exit 1
printf '%s\n' '--- stdin lines ---'
if ! run_stdin_cases lines -l 10000 100000 1000000 10000000; then
exit 1
fi
printf 'benchmarking %s wc vs fastwc: stdin (%s interleaved runs each, minimum kept)\n' \
"$BENCH_NAME" "$BENCH_REPS"
printf '%-28s %10s %22s %8s %s\n' 'test' 'wc' 'fastwc (ms µs)' 'ratio' 'status'
printf '%s\n' '--- stdin words ---'
if ! run_stdin_cases words -w 1000 100000 1000000; then
exit 1
fi
printf '%s\n' '--- stdin lines ---'
if ! run_stdin_cases lines -l 10000 100000 1000000 10000000; then
exit 1
fi
printf '%s\n' '--- stdin lines+words+bytes ---'
if ! run_stdin_cases lines -lwc 1000000; then
exit 1
fi
printf '%s\n' '--- stdin words ---'
if ! run_stdin_cases words -w 1000 100000 1000000; then
exit 1
fi
printf '\nall %s stdin benchmarks passed — fastwc was never slower than %s wc\n' \
"$BENCH_NAME" "$BENCH_NAME"
printf '%s\n' '--- stdin lines+words+bytes ---'
if ! run_stdin_cases lines -lwc 1000000; then
exit 1
fi
printf '\nall %s stdin benchmarks passed — fastwc was never slower than %s wc\n' \
"$BENCH_NAME" "$BENCH_NAME"
done