42 lines
1018 B
Bash
Executable File
42 lines
1018 B
Bash
Executable File
#! /bin/bash
|
|
|
|
baseline_time_s="$1"
|
|
arch=$(uname -m)
|
|
|
|
if [[ $arch = aarch64 ]]; then
|
|
iter=0
|
|
function aarch64_power {
|
|
sensors | awk '/CPU power:/ {print $3; exit}'
|
|
}
|
|
if [[ "$baseline_time_s" -eq -1 ]]; then
|
|
#"${@:2}" 1>/dev/null 2>&1 &
|
|
"${@:2}" 1>&2 2>/dev/null &
|
|
pid=$!
|
|
|
|
while kill -0 $pid 2> /dev/null; do
|
|
aarch64_power
|
|
sleep 1s
|
|
done
|
|
|
|
wait
|
|
else
|
|
while [[ "$iter" -ne "$baseline_time_s" ]]; do
|
|
aarch64_power
|
|
((iter++))
|
|
sleep 1s
|
|
done
|
|
fi
|
|
elif [[ $arch = x86_64 ]]; then
|
|
if [[ "$baseline_time_s" -eq -1 ]]; then
|
|
#turbostat -s PkgWatt -i 1 2>/dev/null | awk -F: '/PkgWatt/ {getline; print $0}'
|
|
#turbostat -s PkgWatt -i 1 | awk '/PkgWatt/ {getline; print $0}'
|
|
turbostat -s PkgWatt ${@:2} 3>&2 2>&1 1>&3 | sed -n "/PkgWatt/{n;n;p}"
|
|
else
|
|
#turbostat -s PkgWatt -n "$baseline_time_s" -i 1 2>/dev/null | awk -F: '/PkgWatt/ {getline; print $0}'
|
|
turbostat -s PkgWatt -n "$baseline_time_s" -i 1 2>/dev/null | sed -n "/PkgWatt/{n;n;p}"
|
|
fi
|
|
else
|
|
echo "Unrecognized arch!"
|
|
exit 1
|
|
fi
|