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.
62 lines
2.0 KiB
Bash
Executable File
62 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# bench.sh — race fastwc against GNU coreutils wc on line counts, file input.
|
|
# Busybox and toybox wc are raced too, for shits and giggles. Includes
|
|
# the monster cases: 100M lines raced against coreutils (busybox/toybox
|
|
# through 1.1 GB is a spectator sport, not a benchmark), and 1B lines
|
|
# timed solo (no reference to beat — there isn't one).
|
|
# 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
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_DIR="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
source "$REPO_DIR/benchmarks/std.sh"
|
|
|
|
checkfastwc
|
|
checkwc
|
|
|
|
for oracle in $ORACLES; do
|
|
select_oracle "$oracle" || exit 1
|
|
|
|
printf 'benchmarking %s wc vs fastwc: lines, file input (%s interleaved runs each, minimum kept)\n' \
|
|
"$BENCH_NAME" "$BENCH_REPS"
|
|
printf '%-28s %16s %24s %8s %s\n' 'test' 'wc' 'fastwc (µs)' 'ratio' 'status'
|
|
|
|
printf '%s\n' '--- lines ---'
|
|
if ! run_cases lines -l 10000 100000 1000000 10000000; then
|
|
exit 1
|
|
fi
|
|
|
|
printf '\n%s\n' '--- longest line ---'
|
|
if ! run_cases lines -L 1000000 10000000; then
|
|
exit 1
|
|
fi
|
|
|
|
|
|
printf '\nall %s lines benchmarks passed — fastwc was never slower than %s wc\n' \
|
|
"$BENCH_NAME" "$BENCH_NAME"
|
|
done
|
|
|
|
# The monsters stay coreutils-only (busybox/toybox through 1.1 GB is a
|
|
# spectator sport, not a benchmark), so switch back from the last oracle
|
|
# raced.
|
|
select_oracle coreutils || exit 1
|
|
printf '%s\n' '--- monster: 100M lines vs coreutils ---'
|
|
if ! run_cases lines -l 100000000; then
|
|
exit 1
|
|
fi
|
|
|
|
printf '%s\n' '--- monster: 1B lines, solo ---'
|
|
run_solo_case 1000000000 -l
|
|
|
|
# A file list is where the worker pool lives, and it needs files big
|
|
# enough that both sides are counting rather than starting. 128 files of
|
|
# about 1.1 MB, 140 MB in total.
|
|
printf '%s\n' '--- file list: 128 files, 12.8M lines, vs coreutils ---'
|
|
if ! run_multi_case lines 128 12800000 -lwc; then
|
|
exit 1
|
|
fi
|