diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2019-11-19 00:18:17 (GMT) |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2019-11-19 00:18:17 (GMT) |
commit | a724e8dbd67ce3d9bf5a24bd836dea4ad3a5516f (patch) | |
tree | 8575f185b5f2e773a7334ffe1dd5891a70bb2151 /tests/run.sh |
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tests/run.sh')
-rwxr-xr-x | tests/run.sh | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..2b32f2a --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,119 @@ +#!/bin/sh -e +# +# PIPAPO - PIle PAcket POlicies +# +# tests/run.sh - Run functional and performance tests, plot matching rates +# +# Author: Stefano Brivio <sbrivio@redhat.com> +# License: GPLv2 + +check() { + if ! ../pipapo.check ${type}.${size} ${type}.${size}.packets >/dev/null; then + echo " functional test: FAIL at ${type}.${size} ${type}.${size}.packets" + exit 1 + fi + echo " functional test: PASS" +} + +pps() { + s="$(wc -l ${type}.${size})" + s=${s% *} + if [ ${s} -gt 10 ]; then + s=$((s / 10)) + s=$((s * 10)) + fi + + pps="$(../pipapo ${type}.${size} ${type}.${size}.packets | sed -nr 's/.* \((.*) Mpps\)$/\1/p')" + printf "%i %f\n" "${s}" "${pps}" >> plots/rate_${type}.data + echo " matching rate (AVX2): ${pps} Mpps" + + pps="$(../pipapo.noavx2 ${type}.${size} ${type}.${size}.packets | sed -nr 's/.* \((.*) Mpps\)$/\1/p')" + printf "%i %f\n" "${s}" "${pps}" >> plots/rate_noavx2_${type}.data + echo " matching rate (no AVX2): ${pps} Mpps" + + pps="$(../pipapo.nosimd ${type}.${size} ${type}.${size}.packets | sed -nr 's/.* \((.*) Mpps\)$/\1/p')" + printf "%i %f\n" "${s}" "${pps}" >> plots/rate_nosimd_${type}.data + echo " matching rate (no SIMD): ${pps} Mpps" +} + +mem() { + s="$(wc -l ${type}.${size})" + s=${s% *} + if [ ${s} -gt 10 ]; then + s=$((s / 10)) + s=$((s * 10)) + fi + + out="$(../pipapo.mem ${type}.${size} ${type}.${size}.packets | sed -nr 's/^Total: ([0-9].*)((KiB$|MiB$|B$))$/\1 \2/p')" + case ${out} in + *" KiB") + _out=$((${out%% *} * 1024)) + ;; + *" MiB") + _out=$((${out%% *} * 1024 * 1024)) + ;; + *" B") + _out=${out%% *} + ;; + esac + + printf "%i %i\n" "${s}" "${_out}" >> plots/memory_${type}.data + + echo " memory used: $(echo ${out} | tr -d ' ')" +} + +[ -d plots ] || { ./gen.sh && mkdir -p plots; } + +plot() { + title="$(echo ${title} | tr '_' ', ')" + gnuplot <<EOF + set terminal pngcairo size 600,400 enhanced font 'Lucida Sans,10' rounded + set logscale x + set xlabel "Entries for each field" + set ylabel "Mpps" + set title '${title}' + set grid + set key right top + set output 'plots/${type}.png' + plot 'plots/rate_${type}.data' w l ls 1 t 'AVX2', 'plots/rate_noavx2_${type}.data' w l ls 2 t 'No AVX2', 'plots/rate_nosimd_${type}.data' w l ls 3 t 'No SIMD' +EOF +} + +for type in port net_port net_port_ranged mac_net6_ranged; do + echo "=== TEST: ${type}" + for size in single tiny small mid big huge; do + :> plots/rate_${type}.data + :> plots/rate_noavx2_${type}.data + :> plots/rate_nosimd_${type}.data + :> plots/memory_${type}.data + done + + for size in single tiny small mid big huge; do + echo " - size: ${size}" + check + pps + mem + done + + plot + + echo +done + +for test in *.static; do + echo "=== TEST: ${test}" + type="${test%*.static}" + :> plots/rate_${type}.data + :> plots/rate_noavx2_${type}.data + :> plots/rate_nosimd_${type}.data + :> plots/memory_${type}.data + size="static" + + check + pps + mem + + echo +done + +exit 0 |