bench.sh copied ipcpath() and the IBus address-file discovery into shell, although the benchmark client only speaks IPC; retrying the client itself is the readiness test. It also forwarded arguments to a daemon that takes exactly one. README claimed Enter confirms the selection, but Enter and Tab commit the reading unless a candidate was moved to.
67 lines
1.2 KiB
Bash
Executable File
67 lines
1.2 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
|
|
|
|
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=
|