1#!/bin/bash 2 3set -eufo pipefail 4 5RUN_BENCH="sudo ./bench -w3 -d10 -a" 6 7function hits() 8{ 9 echo "$*" | sed -E "s/.*hits\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/" 10} 11 12function drops() 13{ 14 echo "$*" | sed -E "s/.*drops\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/" 15} 16 17function header() 18{ 19 local len=${#1} 20 21 printf "\n%s\n" "$1" 22 for i in $(seq 1 $len); do printf '='; done 23 printf '\n' 24} 25 26function summarize() 27{ 28 bench="$1" 29 summary=$(echo $2 | tail -n1) 30 printf "%-20s %s (drops %s)\n" "$bench" "$(hits $summary)" "$(drops $summary)" 31} 32 33header "Single-producer, parallel producer" 34for b in rb-libbpf rb-custom pb-libbpf pb-custom; do 35 summarize $b "$($RUN_BENCH $b)" 36done 37 38header "Single-producer, parallel producer, sampled notification" 39for b in rb-libbpf rb-custom pb-libbpf pb-custom; do 40 summarize $b "$($RUN_BENCH --rb-sampled $b)" 41done 42 43header "Single-producer, back-to-back mode" 44for b in rb-libbpf rb-custom pb-libbpf pb-custom; do 45 summarize $b "$($RUN_BENCH --rb-b2b $b)" 46 summarize $b-sampled "$($RUN_BENCH --rb-sampled --rb-b2b $b)" 47done 48 49header "Ringbuf back-to-back, effect of sample rate" 50for b in 1 5 10 25 50 100 250 500 1000 2000 3000; do 51 summarize "rb-sampled-$b" "$($RUN_BENCH --rb-b2b --rb-batch-cnt $b --rb-sampled --rb-sample-rate $b rb-custom)" 52done 53header "Perfbuf back-to-back, effect of sample rate" 54for b in 1 5 10 25 50 100 250 500 1000 2000 3000; do 55 summarize "pb-sampled-$b" "$($RUN_BENCH --rb-b2b --rb-batch-cnt $b --rb-sampled --rb-sample-rate $b pb-custom)" 56done 57 58header "Ringbuf back-to-back, reserve+commit vs output" 59summarize "reserve" "$($RUN_BENCH --rb-b2b rb-custom)" 60summarize "output" "$($RUN_BENCH --rb-b2b --rb-use-output rb-custom)" 61 62header "Ringbuf sampled, reserve+commit vs output" 63summarize "reserve-sampled" "$($RUN_BENCH --rb-sampled rb-custom)" 64summarize "output-sampled" "$($RUN_BENCH --rb-sampled --rb-use-output rb-custom)" 65 66header "Single-producer, consumer/producer competing on the same CPU, low batch count" 67for b in rb-libbpf rb-custom pb-libbpf pb-custom; do 68 summarize $b "$($RUN_BENCH --rb-batch-cnt 1 --rb-sample-rate 1 --prod-affinity 0 --cons-affinity 0 $b)" 69done 70 71header "Ringbuf, multi-producer contention" 72for b in 1 2 3 4 8 12 16 20 24 28 32 36 40 44 48 52; do 73 summarize "rb-libbpf nr_prod $b" "$($RUN_BENCH -p$b --rb-batch-cnt 50 rb-libbpf)" 74done 75 76