Skip to content

Instantly share code, notes, and snippets.

@ThomasKaiser
Created April 16, 2022 09:13
Show Gist options
  • Save ThomasKaiser/493119ecce14eec6f5ee4d8d8ff50828 to your computer and use it in GitHub Desktop.
Save ThomasKaiser/493119ecce14eec6f5ee4d8d8ff50828 to your computer and use it in GitHub Desktop.
#!/bin/bash
InstallLocation=/usr/local/src
[ -x "${InstallLocation}"/mhz/mhz ] || (echo "You need to run sbc-bench at least once to meet prerequisits" ; exit 1)
TempFile="$(mktemp /tmp/${0##*/}.XXXXXX)"
ReportClockSpeedandTemperature() {
MeasuredSpeed=$(( $(taskset -c 1 "${InstallLocation}"/mhz/mhz 3 100000 | awk -F" cpu_MHz=" '{s+=$2} END {printf "%.0f", s}') / 3 ))
CPUTemp=$(awk '{printf ("%0.1f",$1/1000); }' </sys/devices/virtual/thermal/thermal_zone0/temp)
if [ -s "${TempFile}" ]; then
MIPS="$(awk -F" " '/^Tot:/ {print $4}' <${TempFile} | tail -n1 | tr '\n' ', ' | sed 's/,$//') 7-ZIP MIPS"
else
MIPS="(now starting the benchmark)"
fi
echo -e "${CPUTemp}°C\t${MeasuredSpeed} MHz\t${MIPS}"
} # ReportClockSpeedandTemperature
while true ; do
ReportClockSpeedandTemperature
7zr b >>"${TempFile}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment