bus-bench: decoder stand-in and mixed-load runs
Raw frames to four subscribers plus envelopes to five, at the car's rate and at a full bus. Raw never suffered; envelope deliveries are the load, with the knee near 40,000 deliveries/s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
This commit is contained in:
+13
-9
@@ -6,12 +6,13 @@
|
||||
# usage: bus-bench.sh BUS_BENCH_BINARY CAPTURE.log [secs]
|
||||
# env: BATCHES batch windows in ms, 0 = one message per frame ("0 10")
|
||||
# FLAGS extra options for both roles, e.g. --nagle
|
||||
# SINKS subscribers per run; each reports separately (1)
|
||||
# GAP_MS cangen gap for the full-bus run (0.15: ~4500 frames/s here, past what
|
||||
# 500 kbit/s can carry with 8-byte frames)
|
||||
set -euo pipefail
|
||||
|
||||
BIN="$1"; CAPTURE="$2"; SECS="${3:-20}"
|
||||
BATCHES="${BATCHES:-0 10}"; FLAGS="${FLAGS:-}"
|
||||
BATCHES="${BATCHES:-0 10}"; FLAGS="${FLAGS:-}"; SINKS="${SINKS:-1}"
|
||||
|
||||
if ! ip link show vcan0 >/dev/null 2>&1; then
|
||||
sudo modprobe vcan
|
||||
@@ -26,9 +27,12 @@ OUT=$(mktemp -d)
|
||||
# run NAME BATCH_MS GENERATOR...: the generator feeds vcan0 for a little over SECS seconds.
|
||||
run() {
|
||||
local name="$1" batch="$2"; shift 2
|
||||
# shellcheck disable=SC2086
|
||||
"$BIN" sink --secs "$SECS" $FLAGS > "$OUT/sink" 2>/dev/null &
|
||||
local sink=$!
|
||||
local sinks=() i
|
||||
for i in $(seq "$SINKS"); do
|
||||
# shellcheck disable=SC2086
|
||||
"$BIN" sink --secs "$SECS" $FLAGS > "$OUT/sink$i" 2>/dev/null &
|
||||
sinks+=($!)
|
||||
done
|
||||
sleep 0.5
|
||||
# shellcheck disable=SC2086
|
||||
"$BIN" bridge --batch-ms "$batch" --secs $((SECS + 3)) $FLAGS > "$OUT/bridge" 2>/dev/null &
|
||||
@@ -38,15 +42,15 @@ run() {
|
||||
broker=$(pgrep -x mosquitto); m0=$(ticks "$broker"); t0=$(date +%s.%N)
|
||||
timeout "$((SECS + 1))" "$@" >/dev/null 2>&1 || true
|
||||
m1=$(ticks "$broker"); t1=$(date +%s.%N)
|
||||
wait "$sink" "$bridge"
|
||||
wait "${sinks[@]}" "$bridge"
|
||||
python3 - "$name" "$batch" "$FLAGS" "$OUT" "$((m1 - m0))" "$HZ" "$t0" "$t1" <<'PY'
|
||||
import json, sys
|
||||
import glob, json, sys
|
||||
name, batch, flags, out, ticks, hz, t0, t1 = sys.argv[1:]
|
||||
r = {"run": name, "batch_ms": int(batch), "flags": flags,
|
||||
"sink": json.load(open(f"{out}/sink")), "bridge": json.load(open(f"{out}/bridge")),
|
||||
"sinks": [json.load(open(p)) for p in sorted(glob.glob(f"{out}/sink*"))], "bridge": json.load(open(f"{out}/bridge")),
|
||||
"mosquitto_cpu_pct": round(100 * int(ticks) / int(hz) / (float(t1) - float(t0)), 1)}
|
||||
for k in ("role",):
|
||||
r["sink"].pop(k); r["bridge"].pop(k)
|
||||
for d in r["sinks"] + [r["bridge"]]:
|
||||
d.pop("role")
|
||||
print(json.dumps(r))
|
||||
PY
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user