Race -L and the file list in the benchmark suite

The numbers for -L and for a long file list lived in a scratch harness,
so nothing in the repository would fail if either regressed. The lines
suite now races -L at 1M and 10M lines against every oracle, and ends
with 128 files holding 12.8M lines counted in one invocation, which is
where the worker pool lives.

The file-list check compares the row count and the total row's numbers
rather than the whole output: busybox and toybox pad their columns
differently, and an exact string compare would fail on their formatting
instead of on our arithmetic.
This commit is contained in:
2026-11-15 13:58:13 -05:00
parent 47188fbef1
commit 9b68ad4c6c
4 changed files with 66 additions and 3 deletions
+42
View File
@@ -403,6 +403,48 @@ run_cases() {
return $rc
}
# run_multi_case <mode> <files> <lines total> <flag> — race a list of files.
# A list is where the worker pool lives: one file per worker, rows printed
# in argument order. Correctness is the whole output, not one column,
# because a pool that reorders or drops a row would still total up.
run_multi_case() {
local mode="$1" nfiles="$2" lines="$3" flag="$4"
local label="$mode (${nfiles} files, ${lines} lines)"
local src dir name i d wc_out fast_out wc_us fast_us
local -a files=()
src=$(createtxt "$lines") || return 1
dir="$DATA_DIR/multi-${nfiles}-${lines}"
if [[ ! -f "$dir/.ready" ]]; then
rm -rf "$dir"
mkdir -p "$dir"
split -n "$nfiles" -d -a 3 "$src" "$dir/part-" || return 1
: > "$dir/.ready"
fi
for name in "$dir"/part-*; do
files+=("$name")
done
# The oracles pad their columns differently, so the check is the row
# count (nothing dropped or reordered) and the total row's numbers.
wc_out=$("${WC_CMD[@]}" "$flag" "${files[@]}" 2>/dev/null |
awk 'END { print NR ":" $1, $2, $3 }')
fast_out=$("$FASTWC" "$flag" "${files[@]}" 2>/dev/null |
awk 'END { print NR ":" $1, $2, $3 }')
wc_us=''
fast_us=''
for ((i = 0; i < BENCH_REPS; i++)); do
d=$(timeit "${WC_CMD[@]}" "$flag" "${files[@]}")
[[ -z "$wc_us" || "$d" -lt "$wc_us" ]] && wc_us="$d"
d=$(timeit "$FASTWC" "$flag" "${files[@]}")
[[ -z "$fast_us" || "$d" -lt "$fast_us" ]] && fast_us="$d"
done
finish_race "$label" "$wc_out" "$fast_out" "$wc_us" "$fast_us"
}
# run_stdin_cases <words|lines> <-w|-l|...> <size...> — run run_stdin_case
# for every size, stopping at the first failure.
run_stdin_cases() {