#!/usr/bin/env bash # scripts/bench-client.sh — M8 benchmark harness (Client side) # Runs the simulator locally, pointing to a remote substrate server. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$ROOT" SUBSTRATE_IP="${1:-}" if [[ -z "$SUBSTRATE_IP" ]]; then echo "Usage: ./scripts/bench-client.sh " exit 1 fi WARMUP_S="${WARMUP_S:-20}" WINDOW_S="${WINDOW_S:-50}" RATE_HZ="${RATE_HZ:-100}" BUILD="${BUILD:-release}" SIMULATOR="$ROOT/target/$BUILD/simulator" if [[ ! -x "$SIMULATOR" ]]; then echo "Building simulator..." cargo build --release -p simulator SIMULATOR="$ROOT/target/release/simulator" fi ENTITIES_LIST=(10000 50000 100000 200000) LOSS_LIST=(0 1 5) for entities in "${ENTITIES_LIST[@]}"; do devices=$(( entities / 5 )) for loss in "${LOSS_LIST[@]}"; do echo "" echo "==================================================" echo "Configuration: $entities entities, $loss% loss" echo "==================================================" read -p "Press Enter to start simulator for $((WARMUP_S + WINDOW_S + 5)) seconds..." /dev/null || true wait "$SIM_PID" 2>/dev/null || true done done echo "All benchmark client runs complete!"