Files
settled-reach/tests/run-ipc-benchmark
T
jpmschweitzerandClaude Opus 4.6 af3398ea34 fix(ci): address PR #69 review — stale comments, dead CLI flags
- gen_fixtures.rs: version comments now say PROTOCOL_VERSION instead
  of hardcoded 14, so they stay correct across bumps
- run-ipc-benchmark: remove --iterations flag that was parsed but
  never forwarded to the Rust test (compile-time constant governs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 13:10:23 +01:00

56 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# tests/run-ipc-benchmark: IPC round-trip latency benchmark (#342, D-020)
#
# Runs server/tests/ipc_bench.rs via `cargo test --release --test ipc_bench`.
# Parses IPC_BENCH_RESULT:{json} from output and outputs the result JSON.
#
# Latency budget: p99 <= 5ms (D-020: "~1-5ms serialization latency per tick").
#
# NOTE (#342): Handshake step is stubbed in ipc_bench.rs pending #555 (server
# protocol handshake) and #556 (client handshake). Full clean timing requires
# a working handshake before the measurement loop starts.
#
# Exit: 0 = benchmark passed (p99 within threshold), non-zero = failure
# Stdout: {"p50_ms":N,"p95_ms":N,"p99_ms":N,"threshold_ms":5,"passed":true,"rounds":100}
set -euo pipefail
THRESHOLD_MS=5
while [[ $# -gt 0 ]]; do
case "$1" in
--filter) shift 2 ;; # ignored — benchmark has no test filter
--filter=*) shift ;;
*) echo "Unknown argument: $1" >&2; exit 2 ;;
esac
done
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
START_MS=$(date +%s%3N)
TMPOUT=$(mktemp)
set +e
cd "$REPO_ROOT/server" && \
cargo test --release --test ipc_bench -- --ignored --nocapture 2>&1 | tee "$TMPOUT" >&2
EXIT_CODE=${PIPESTATUS[0]}
set -e
END_MS=$(date +%s%3N)
DURATION_MS=$((END_MS - START_MS))
# Extract IPC_BENCH_RESULT:{json} line from output
RESULT_LINE=$(grep "^IPC_BENCH_RESULT:" "$TMPOUT" | tail -1 || true)
rm -f "$TMPOUT"
if [[ -n "$RESULT_LINE" ]]; then
# Strip the prefix and output the JSON
echo "${RESULT_LINE#IPC_BENCH_RESULT:}"
else
# No result line — test failed to produce output
printf '{"p50_ms":0,"p95_ms":0,"p99_ms":0,"threshold_ms":%d,"passed":false,"error":"no benchmark output — server binary may not be built (run make build-server)"}\n' \
"$THRESHOLD_MS"
EXIT_CODE=1
fi
exit $EXIT_CODE