Nacre/tests/smoke/integ-idle-cpu.sh

16 lines
768 B
Shell
Executable file

#!/usr/bin/env bash
# CPU use of an idle Nacre (S009): tests/smoke/integ-idle-cpu.sh <outdir>. Needs the page server on 8768.
# Samples utime+stime of the browser over 20 s, after 15 s of settling; fails above 10 % of one core.
out=${1:?usage: integ-idle-cpu.sh <outdir>}
root=$(cd "$(dirname "$0")/../.." && pwd)
"$root/tools/smoke.sh" "$root/tests/smoke/integ-idle.txt" "$out" &
smoke=$!
sleep 15
pid=$(pgrep -n -f "$root/target/release/nacre")
[ -n "$pid" ] || { echo "FAIL: browser not running"; exit 1; }
ticks() { awk '{print $14+$15}' "/proc/$pid/stat"; }
a=$(ticks); sleep 20; b=$(ticks)
wait "$smoke"
pct=$(( (b - a) * 100 / (20 * $(getconf CLK_TCK)) ))
echo "idle CPU: $pct % of one core"
[ "$pct" -le 10 ] && echo "ok" || { echo "FAIL: too high"; exit 1; }