bench: microsecond timing via tools/timeit, toybox oracle, words to 10M lines

This commit is contained in:
2026-09-09 05:23:54 -04:00
parent 7b3a535173
commit 3cde946a68
7 changed files with 186 additions and 138 deletions
+10 -4
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
# test-all.sh — compile the benchmark helper tools first, then run every
# benchmark suite (words, lines incl. monsters, stdin) against every
# oracle found (coreutils, plus busybox for shits and giggles). Exits
# non-zero if any of them fails, and ends with the average speedup of
# fastwc against each oracle.
# oracle found (coreutils, plus busybox and toybox for shits and
# giggles). Exits non-zero if any of them fails, and ends with the
# average speedup of fastwc against each oracle.
#
# usage: ./test-all.sh
set -u
@@ -19,13 +19,19 @@ export RATIOS_FILE
source "$SCRIPT_DIR/std.sh"
# 1. build the helper tools before running any benchmark so createtxt()
# can use the fast C generator instead of the slow shell fallback
# can use the fast C generator instead of the slow shell fallback and
# the races are timed at µs resolution
mkdir -p "$SCRIPT_DIR/tools"
if ! cc -O2 -Wall -o "$SCRIPT_DIR/tools/genfile" "$SCRIPT_DIR/tools/genfile.c"; then
printf 'test-all: error: failed to compile %s\n' "$SCRIPT_DIR/tools/genfile.c" >&2
exit 1
fi
printf 'built %s\n' "$SCRIPT_DIR/tools/genfile"
if ! cc -O2 -Wall -o "$SCRIPT_DIR/tools/timeit" "$SCRIPT_DIR/tools/timeit.c"; then
printf 'test-all: error: failed to compile %s\n' "$SCRIPT_DIR/tools/timeit.c" >&2
exit 1
fi
printf 'built %s\n' "$SCRIPT_DIR/tools/timeit"
# 2. run each suite (all run regardless, so every result is reported)
"$SCRIPT_DIR/files/words/bench.sh"