Path: blob/master/tools/testing/selftests/bpf/benchs/run_common.sh
29270 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.023RUN_BENCH="sudo ./bench -w3 -d10 -a"45function header()6{7local len=${#1}89printf "\n%s\n" "$1"10for i in $(seq 1 $len); do printf '='; done11printf '\n'12}1314function subtitle()15{16local len=${#1}17printf "\t%s\n" "$1"18}1920function hits()21{22echo "$*" | sed -E "s/.*hits\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"23}2425function drops()26{27echo "$*" | sed -E "s/.*drops\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"28}2930function percentage()31{32echo "$*" | sed -E "s/.*Percentage\s=\s+([0-9]+\.[0-9]+).*/\1/"33}3435function ops()36{37echo -n "throughput: "38echo -n "$*" | sed -E "s/.*throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"39echo -n -e ", latency: "40echo "$*" | sed -E "s/.*latency\s+([0-9]+\.[0-9]+\sns\/op).*/\1/"41}4243function local_storage()44{45echo -n "hits throughput: "46echo -n "$*" | sed -E "s/.* hits throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"47echo -n -e ", hits latency: "48echo -n "$*" | sed -E "s/.* hits latency\s+([0-9]+\.[0-9]+\sns\/op).*/\1/"49echo -n ", important_hits throughput: "50echo "$*" | sed -E "s/.*important_hits throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"51}5253function total()54{55echo "$*" | sed -E "s/.*total operations\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"56}5758function summarize()59{60bench="$1"61summary=$(echo $2 | tail -n1)62printf "%-20s %s (drops %s)\n" "$bench" "$(hits $summary)" "$(drops $summary)"63}6465function summarize_percentage()66{67bench="$1"68summary=$(echo $2 | tail -n1)69printf "%-20s %s%%\n" "$bench" "$(percentage $summary)"70}7172function summarize_ops()73{74bench="$1"75summary=$(echo $2 | tail -n1)76printf "%-20s %s\n" "$bench" "$(ops $summary)"77}7879function summarize_local_storage()80{81bench="$1"82summary=$(echo $2 | tail -n1)83printf "%-20s %s\n" "$bench" "$(local_storage $summary)"84}8586function summarize_total()87{88bench="$1"89summary=$(echo $2 | tail -n1)90printf "%-20s %s\n" "$bench" "$(total $summary)"91}929394