1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4RUN_BENCH="sudo ./bench -w3 -d10 -a" 5 6function header() 7{ 8 local len=${#1} 9 10 printf "\n%s\n" "$1" 11 for i in $(seq 1 $len); do printf '='; done 12 printf '\n' 13} 14 15function subtitle() 16{ 17 local len=${#1} 18 printf "\t%s\n" "$1" 19} 20 21function hits() 22{ 23 echo "$*" | sed -E "s/.*hits\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/" 24} 25 26function drops() 27{ 28 echo "$*" | sed -E "s/.*drops\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/" 29} 30 31function percentage() 32{ 33 echo "$*" | sed -E "s/.*Percentage\s=\s+([0-9]+\.[0-9]+).*/\1/" 34} 35 36function total() 37{ 38 echo "$*" | sed -E "s/.*total operations\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/" 39} 40 41function summarize() 42{ 43 bench="$1" 44 summary=$(echo $2 | tail -n1) 45 printf "%-20s %s (drops %s)\n" "$bench" "$(hits $summary)" "$(drops $summary)" 46} 47 48function summarize_percentage() 49{ 50 bench="$1" 51 summary=$(echo $2 | tail -n1) 52 printf "%-20s %s%%\n" "$bench" "$(percentage $summary)" 53} 54 55function summarize_total() 56{ 57 bench="$1" 58 summary=$(echo $2 | tail -n1) 59 printf "%-20s %s\n" "$bench" "$(total $summary)" 60} 61