cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

run_common.sh (1437B)


      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 ops()
     37{
     38	echo -n "throughput: "
     39	echo -n "$*" | sed -E "s/.*throughput\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+\sM\sops\/s).*/\1/"
     40	echo -n -e ", latency: "
     41	echo "$*" | sed -E "s/.*latency\s+([0-9]+\.[0-9]+\sns\/op).*/\1/"
     42}
     43
     44function total()
     45{
     46	echo "$*" | sed -E "s/.*total operations\s+([0-9]+\.[0-9]+ ± [0-9]+\.[0-9]+M\/s).*/\1/"
     47}
     48
     49function summarize()
     50{
     51	bench="$1"
     52	summary=$(echo $2 | tail -n1)
     53	printf "%-20s %s (drops %s)\n" "$bench" "$(hits $summary)" "$(drops $summary)"
     54}
     55
     56function summarize_percentage()
     57{
     58	bench="$1"
     59	summary=$(echo $2 | tail -n1)
     60	printf "%-20s %s%%\n" "$bench" "$(percentage $summary)"
     61}
     62
     63function summarize_ops()
     64{
     65	bench="$1"
     66	summary=$(echo $2 | tail -n1)
     67	printf "%-20s %s\n" "$bench" "$(ops $summary)"
     68}
     69
     70function summarize_total()
     71{
     72	bench="$1"
     73	summary=$(echo $2 | tail -n1)
     74	printf "%-20s %s\n" "$bench" "$(total $summary)"
     75}