#!/bin/sh -e # # PIPAPO - PIle PAcket POlicies # # tests/run.sh - Run functional and performance tests, plot matching rates # # Author: Stefano Brivio # 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 < 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