Skip to content

Instantly share code, notes, and snippets.

@erig0
Created May 25, 2023 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erig0/aaef1ca59f285323dcacf66255244c60 to your computer and use it in GitHub Desktop.
Save erig0/aaef1ca59f285323dcacf66255244c60 to your computer and use it in GitHub Desktop.
nftables flowtable performance script
#!/bin/sh
test -z "${1}" && { printf "Must specify iperf3 server address as first argument."; exit 1; }
test -z "${2}" && { printf "Must specify iperf3 server network namespace as second argument."; exit 1; }
HOST="${1}"
NS="${2}"
NUM_INSTANCES=16
NUM_RUNS=10
rm ./runs &>/dev/null || true
for run in $(seq ${NUM_RUNS}); do
for I in $(seq ${NUM_INSTANCES}); do
ip netns exec ${NS} iperf3 -s -1 -p 500${I} -i 0 >/dev/null 2>/dev/null &
done
sleep 5
for I in $(seq ${NUM_INSTANCES}); do
(iperf3 -J -p 500${I} -c ${HOST} -i 0 -O 10 -t 60 -Z -P 128 2>/dev/null | jq '.end.sum_received.bits_per_second' > ./bps-${I} ;) &
done
wait
bc <<-HERE >> ./runs
$(cat ./bps-* |while read LINE; do
printf "${LINE} + "
done) 0
HERE
rm -f ./bps-*
done
bc <<-HERE > ./mean
scale=2
($(cat ./runs |while read LINE; do
printf "${LINE} + "
done) 0) / ${NUM_RUNS}
HERE
bc <<-HERE > ./stddev
scale=2
sqrt( ($(cat ./runs |while read LINE; do
printf "(${LINE} - $(cat ./mean))^2 + "
done) 0) / (${NUM_RUNS} - 1) )
HERE
printf "\n"
printf "BPS (all): %s\n" "$(cat ./runs)"
printf "BPS (mean): %s\n" "$(cat ./mean)"
printf "stddev: %s\n" "$(cat ./stddev)"
rm ./runs
rm ./mean
rm ./stddev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment