WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / benchs / run_bench_ringbufs.sh
blobaf4aa04caba6a62f29a7de4032bbbfe0766dfc61
1 #!/bin/bash
3 set -eufo pipefail
5 RUN_BENCH="sudo ./bench -w3 -d10 -a"
7 function hits()
9 echo "$*" | sed -E "s/.*hits\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
12 function drops()
14 echo "$*" | sed -E "s/.*drops\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
17 function header()
19 local len=${#1}
21 printf "\n%s\n" "$1"
22 for i in $(seq 1 $len); do printf '='; done
23 printf '\n'
26 function summarize()
28 bench="$1"
29 summary=$(echo $2 | tail -n1)
30 printf "%-20s %s (drops %s)\n" "$bench" "$(hits $summary)" "$(drops $summary)"
33 header "Single-producer, parallel producer"
34 for b in rb-libbpf rb-custom pb-libbpf pb-custom; do
35 summarize $b "$($RUN_BENCH $b)"
36 done
38 header "Single-producer, parallel producer, sampled notification"
39 for b in rb-libbpf rb-custom pb-libbpf pb-custom; do
40 summarize $b "$($RUN_BENCH --rb-sampled $b)"
41 done
43 header "Single-producer, back-to-back mode"
44 for 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)"
47 done
49 header "Ringbuf back-to-back, effect of sample rate"
50 for 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)"
52 done
53 header "Perfbuf back-to-back, effect of sample rate"
54 for 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)"
56 done
58 header "Ringbuf back-to-back, reserve+commit vs output"
59 summarize "reserve" "$($RUN_BENCH --rb-b2b rb-custom)"
60 summarize "output" "$($RUN_BENCH --rb-b2b --rb-use-output rb-custom)"
62 header "Ringbuf sampled, reserve+commit vs output"
63 summarize "reserve-sampled" "$($RUN_BENCH --rb-sampled rb-custom)"
64 summarize "output-sampled" "$($RUN_BENCH --rb-sampled --rb-use-output rb-custom)"
66 header "Single-producer, consumer/producer competing on the same CPU, low batch count"
67 for 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)"
69 done
71 header "Ringbuf, multi-producer contention"
72 for 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)"
74 done