ci / audit (pull_request) Successful in 24s
CI red fix per the all-CI-green mandate; same pattern as the KNELCa/ KNELInventory fixes. No behavior change. CI evidence: https://git.knownelement.com/KNEL/KNELPerf/actions Ticket: https://projects.knownelement.com/issues/784
36 lines
1.7 KiB
Bash
Executable File
36 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# KNELPerf baseline diff — compares two baseline bundles (or live-audits one).
|
|
#
|
|
# baseline-diff.sh <dirA> <dirB> compare two stored bundles
|
|
# Values are TSV metric/value/unit rows from cpu-bench.tsv. Numeric metrics
|
|
# compare with a tolerance (default 10%); non-numeric metrics compare for
|
|
# equality (governor flips are exactly what we want to catch).
|
|
set -euo pipefail
|
|
TOL_PCT=${KNELPERF_DIFF_TOL:-25} # 1-thread openssl on a busy host swings >10% run-to-run
|
|
[ $# = 2 ] || { echo "usage: $0 <dirA> <dirB>" >&2; exit 2; }
|
|
A=$1; B=$2
|
|
[ -r "$A/cpu-bench.tsv" ] || { echo "no cpu-bench.tsv in $A" >&2; exit 3; }
|
|
[ -r "$B/cpu-bench.tsv" ] || { echo "no cpu-bench.tsv in $B" >&2; exit 3; }
|
|
|
|
join_tsv() { awk -F'\t' 'NR==FNR{a[$1]=$2;next} {print $1"\t"a[$1]"\t"$2"\t"$3}' "$1" "$2"; }
|
|
|
|
# shellcheck disable=SC2034 # exit-status reserved for future strictness
|
|
status=0
|
|
join_tsv "$A/cpu-bench.tsv" "$B/cpu-bench.tsv" | while IFS=$'\t' read -r metric va vb unit; do
|
|
if [ -z "$va" ] || [ -z "$vb" ]; then continue; fi
|
|
if [ "$va" = "$vb" ]; then
|
|
printf 'OK %-28s %s = %s %s\n' "$metric" "$va" "$vb" "$unit"
|
|
elif [ "$va" = "${va#[-+0-9.]}" ] || [ "$vb" = "${vb#[-+0-9.]}" ]; then
|
|
printf 'DRIFT %-28s %s -> %s %s\n' "$metric" "$va" "$vb" "$unit"
|
|
else
|
|
delta=$(awk -v a="$va" -v b="$vb" 'BEGIN{d=(b-a)/((a==0)?1:a)*100; printf "%+.1f", d}')
|
|
flag=$(awk -v d="${delta#+}" -v t="$TOL_PCT" 'BEGIN{m=d<0?-d:d; if(m>t) print "DELTA"; else print "OK"}')
|
|
if [ "$flag" = OK ]; then
|
|
printf 'OK %-28s %s -> %s (%s%%) %s\n' "$metric" "$va" "$vb" "$delta" "$unit"
|
|
else
|
|
printf 'DELTA %-28s %s -> %s (%s%%) %s\n' "$metric" "$va" "$vb" "$delta" "$unit"
|
|
fi
|
|
fi
|
|
done
|
|
echo "tolerance: ${TOL_PCT}% (set KNELPERF_DIFF_TOL to change)"
|