Files
strans/bench.sh
Hojun-Cho 0ba7dc7f50 build, data: the Greek capitals by name; one way to run python3; bench.sh checks its own binary
Δ Γ Λ Ω Φ Ψ Σ Θ answered only to De, Ga, La, Om, Ph, Ps, Si, Th, while
their small letters answered to delta, gamma and the rest; they answer to
the names too now.  mkemoji and cldr2emoji write UTF-8 whatever the
locale, as the other generators already did; verify-map calls python3 the
one way; the tests' include path drops a directory nothing includes
through; and bench.sh says which binary is missing instead of blaming the
daemon ten seconds later.
2026-08-17 12:17:18 +09:00

72 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
set -eu
cd "$(dirname "$0")" || exit 1
if test "$#" -ne 0; then
echo "usage: bench.sh" >&2
exit 1
fi
if ! test -x ./bench/bench; then
echo "bench.sh: ./bench/bench is not executable; run make bench first" >&2
exit 1
fi
strans_pid=
perf_pid=
cleanup()
{
status=$?
trap - 0 1 2 15
if test -n "$perf_pid"; then
kill -INT "$perf_pid" 2>/dev/null || :
wait "$perf_pid" 2>/dev/null || :
fi
if test -n "$strans_pid"; then
kill "$strans_pid" 2>/dev/null || :
wait "$strans_pid" 2>/dev/null || :
fi
exit "$status"
}
trap cleanup 0
trap 'exit 129' 1
trap 'exit 130' 2
trap 'exit 143' 15
./strans map &
strans_pid=$!
# The daemon is ready once the benchmark client can complete a round.
attempt=0
until ./bench/bench bench/bench.keys 1 >/dev/null 2>&1; do
if ! kill -0 "$strans_pid" 2>/dev/null; then
echo "bench.sh: daemon exited before accepting IPC clients" >&2
exit 1
fi
attempt=$((attempt + 1))
if test "$attempt" -ge 50; then
echo "bench.sh: daemon did not accept IPC clients within 10 seconds" >&2
exit 1
fi
sleep 0.2
done
# warm up the renderer
./bench/bench bench/bench.keys 100
echo "renderer warmed up"
perf record -g -o bench/perf.data -p "$strans_pid" &
perf_pid=$!
sleep 1
kill -0 "$perf_pid"
./bench/bench bench/bench.keys 100
kill -INT "$perf_pid"
wait "$perf_pid" 2>/dev/null || :
perf_pid=