diff --git a/benchmark_network.sh b/benchmark_network.sh index 8b0ceb7..1407216 100755 --- a/benchmark_network.sh +++ b/benchmark_network.sh @@ -232,22 +232,25 @@ run_fastsync() { local output output=$(timeout 600 "$CLIENT_BIN" -h "$HOST" -p "$port" -s "$SRC_DIR" -n "$nconn" 2>&1) || true - # With network latency, wait for all data to be written and synced to disk - # For 1 connection: much more time needed as data is sequential - # For high latency: extra margin for TCP retransmissions and jitter - local wait_time=5 - if [ "$nconn" -eq 1 ]; then - wait_time=$(( 15 + LATENCY_MS / 5 + (DATA_SIZE_MB / 20) )) - else - wait_time=$(( 5 + LATENCY_MS / 10 + (DATA_SIZE_MB / 50) )) - fi - [ "$wait_time" -lt 10 ] && wait_time=10 + # Extract actual transfer time from client output + local transfer_ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0") + local transfer_ms_int=$(echo "$transfer_ms" | awk '{printf "%d", $1+0}') + + # Wait: transfer time + latency-based margin + disk sync margin + # For 1 connection, add extra margin as it's sequential + local latency_margin=$(( LATENCY_MS * 2 )) + local sync_margin=3 + local extra_for_1conn=0 + [ "$nconn" -eq 1 ] && extra_for_1conn=5 + + local wait_time=$(( transfer_ms_int / 1000 + latency_margin / 10 + sync_margin + extra_for_1conn )) + [ "$wait_time" -lt 5 ] && wait_time=5 sleep $wait_time kill "$spid" 2>/dev/null || true wait "$spid" 2>/dev/null || true sync - sleep 2 + sleep 1 local ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0") local mbs=$(echo "$output" | grep -oP 'throughput_mbs=\K[0-9.]+' || echo "0")