Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 RUN_BENCH="sudo ./bench -w3 -d10 -a"
0005 
0006 function header()
0007 {
0008         local len=${#1}
0009 
0010         printf "\n%s\n" "$1"
0011         for i in $(seq 1 $len); do printf '='; done
0012         printf '\n'
0013 }
0014 
0015 function subtitle()
0016 {
0017         local len=${#1}
0018         printf "\t%s\n" "$1"
0019 }
0020 
0021 function hits()
0022 {
0023         echo "$*" | sed -E "s/.*hits\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
0024 }
0025 
0026 function drops()
0027 {
0028         echo "$*" | sed -E "s/.*drops\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
0029 }
0030 
0031 function percentage()
0032 {
0033         echo "$*" | sed -E "s/.*Percentage\s=\s+([0-9]+\.[0-9]+).*/\1/"
0034 }
0035 
0036 function ops()
0037 {
0038         echo -n "throughput: "
0039         echo -n "$*" | sed -E "s/.*throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"
0040         echo -n -e ", latency: "
0041         echo "$*" | sed -E "s/.*latency\s+([0-9]+\.[0-9]+\sns\/op).*/\1/"
0042 }
0043 
0044 function local_storage()
0045 {
0046         echo -n "hits throughput: "
0047         echo -n "$*" | sed -E "s/.* hits throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"
0048         echo -n -e ", hits latency: "
0049         echo -n "$*" | sed -E "s/.* hits latency\s+([0-9]+\.[0-9]+\sns\/op).*/\1/"
0050         echo -n ", important_hits throughput: "
0051         echo "$*" | sed -E "s/.*important_hits throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"
0052 }
0053 
0054 function total()
0055 {
0056         echo "$*" | sed -E "s/.*total operations\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
0057 }
0058 
0059 function summarize()
0060 {
0061         bench="$1"
0062         summary=$(echo $2 | tail -n1)
0063         printf "%-20s %s (drops %s)\n" "$bench" "$(hits $summary)" "$(drops $summary)"
0064 }
0065 
0066 function summarize_percentage()
0067 {
0068         bench="$1"
0069         summary=$(echo $2 | tail -n1)
0070         printf "%-20s %s%%\n" "$bench" "$(percentage $summary)"
0071 }
0072 
0073 function summarize_ops()
0074 {
0075         bench="$1"
0076         summary=$(echo $2 | tail -n1)
0077         printf "%-20s %s\n" "$bench" "$(ops $summary)"
0078 }
0079 
0080 function summarize_local_storage()
0081 {
0082         bench="$1"
0083         summary=$(echo $2 | tail -n1)
0084         printf "%-20s %s\n" "$bench" "$(local_storage $summary)"
0085 }
0086 
0087 function summarize_total()
0088 {
0089         bench="$1"
0090         summary=$(echo $2 | tail -n1)
0091         printf "%-20s %s\n" "$bench" "$(total $summary)"
0092 }