63 lines
1.8 KiB
Bash
Executable File
63 lines
1.8 KiB
Bash
Executable File
#!/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 <SUBSTRATE_IP>"
|
|
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/tty
|
|
|
|
sim_args=(
|
|
--addr "$SUBSTRATE_IP:9000"
|
|
--profile industrial
|
|
--rate-hz "$RATE_HZ"
|
|
--count 0
|
|
--devices "$devices"
|
|
)
|
|
|
|
# Run in background
|
|
RUST_LOG=warn "$SIMULATOR" "${sim_args[@]}" &
|
|
SIM_PID=$!
|
|
|
|
sleep_time=$((WARMUP_S + WINDOW_S + 5))
|
|
echo "Simulator running. Waiting ${sleep_time}s..."
|
|
sleep "$sleep_time"
|
|
|
|
kill -TERM "$SIM_PID" 2>/dev/null || true
|
|
wait "$SIM_PID" 2>/dev/null || true
|
|
done
|
|
done
|
|
|
|
echo "All benchmark client runs complete!"
|