Files
lucisv/tools/perf/sweep.sh
T

55 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# The timed CLI sweeps: `format --check` (cold and warm cache) and `check`
# (default rules, and `--select error,warning,style`) over five opentitan
# trees, one binary at a time, three tries per cell, wall clock and peak RSS
# from `/usr/bin/time -l`.
#
# tools/perf/sweep.sh <lucisv-binary> <label> <opentitan-dir> <out-dir> [tries]
#
# Each cell writes `<out-dir>/<label>__<tree>__<command>__<cache>.txt`, which
# holds the three runs' `/usr/bin/time -l` blocks; `sweeptable.py` reads them.
# The formatter cache is a scratch `--cache-dir` under `<out-dir>`, so nothing
# is ever written into the corpus.
#
# Every `lucisv` invocation goes through `tools/guard.sh -m 8 -t 1800`.
set -u
BIN=${1:?usage: sweep.sh <binary> <label> <opentitan> <outdir> [tries]}
LABEL=${2:?}
OT=${3:?}
OUT=${4:?}
TRIES=${5:-3}
HERE=$(cd "$(dirname "$0")" && pwd)
GUARD="$HERE/../guard.sh"
CACHE="$OUT/fmtcache"
TREES="hw/ip hw/top_earlgrey/ip hw/top_darjeeling/ip hw/dv hw/vendor"
mkdir -p "$OUT"
run_cell() {
local tree=$1 name=$2 cache=$3
shift 3
local safe=${tree//\//_}
local log="$OUT/${LABEL}__${safe}__${name}__${cache}.txt"
: >"$log"
if [ "$cache" = cold ]; then rm -rf "$CACHE"; fi
local i
for i in $(seq 1 "$TRIES"); do
echo "--- try $i ---" >>"$log"
# `-l` puts the resource block on stderr; both streams are kept.
"$GUARD" -m 8 -t 1800 -- /usr/bin/time -l "$BIN" "$@" >>"$log" 2>>"$log"
echo "--- exit $? ---" >>"$log"
done
echo "$log"
}
for tree in $TREES; do
echo "== $LABEL $tree"
run_cell "$tree" format cold format --cache-dir "$CACHE" --check "$OT/$tree"
run_cell "$tree" format warm format --cache-dir "$CACHE" --check "$OT/$tree"
run_cell "$tree" check default check "$OT/$tree"
run_cell "$tree" check select check --select error,warning,style "$OT/$tree"
done