Update to scripts

This commit is contained in:
Valère Plantevin
2026-05-13 09:58:30 -04:00
parent 7f54aea439
commit 6e60c760b0
3 changed files with 142 additions and 13 deletions

View File

@@ -15,6 +15,7 @@ WINDOW_S="${WINDOW_S:-50}"
RATE_HZ="${RATE_HZ:-100}"
BUILD="${BUILD:-release}"
IFACE="${IFACE:-eth0}"
RUN_SIMULATOR="${RUN_SIMULATOR:-1}"
OUT_CSV="${OUT_CSV:-data/loopback/final_table.csv}"
@@ -46,11 +47,19 @@ done
step "Building ($BUILD)"
if [[ "$BUILD" == "release" ]]; then
cargo build --release -p substrate -p simulator >/dev/null
if [[ "$RUN_SIMULATOR" -eq 1 ]]; then
cargo build --release -p substrate -p simulator >/dev/null
else
cargo build --release -p substrate >/dev/null
fi
SUBSTRATE="$ROOT/target/release/substrate"
SIMULATOR="$ROOT/target/release/simulator"
else
cargo build -p substrate -p simulator >/dev/null
if [[ "$RUN_SIMULATOR" -eq 1 ]]; then
cargo build -p substrate -p simulator >/dev/null
else
cargo build -p substrate >/dev/null
fi
SUBSTRATE="$ROOT/target/debug/substrate"
SIMULATOR="$ROOT/target/debug/simulator"
fi
@@ -116,14 +125,19 @@ for entities in "${ENTITIES_LIST[@]}"; do
fi
fi
sim_args=(
--profile industrial
--rate-hz "$RATE_HZ"
--count 0
--devices "$devices"
)
RUST_LOG=warn "$SIMULATOR" "${sim_args[@]}" >"$LOG_DIR/sim_${entities}_${loss}.log" 2>&1 &
SIM_PID=$!
if [[ "$RUN_SIMULATOR" -eq 1 ]]; then
sim_args=(
--profile industrial
--rate-hz "$RATE_HZ"
--count 0
--devices "$devices"
)
RUST_LOG=warn "$SIMULATOR" "${sim_args[@]}" >"$LOG_DIR/sim_${entities}_${loss}.log" 2>&1 &
SIM_PID=$!
else
echo -e "\n${BOLD}Ready for: $entities entities, $loss% loss${RESET}"
read -p "Press Enter to begin recording (ensure Mac simulator is started)..." </dev/tty
fi
sleep "$WARMUP_S"
snapshot_to "$BEFORE"
@@ -133,9 +147,11 @@ for entities in "${ENTITIES_LIST[@]}"; do
sleep "$WINDOW_S"
snapshot_to "$AFTER"
kill -TERM "$SIM_PID" 2>/dev/null || true
wait "$SIM_PID" 2>/dev/null || true
SIM_PID=""
if [[ "$RUN_SIMULATOR" -eq 1 ]]; then
kill -TERM "$SIM_PID" 2>/dev/null || true
wait "$SIM_PID" 2>/dev/null || true
SIM_PID=""
fi
rec_after=$(get_value "$AFTER" 'substrate_received_total\{tier="t1"\}')
drop_after=$(get_value "$AFTER" 'substrate_dropped_total\{tier="t1"\}')