Skip to content

Instantly share code, notes, and snippets.

@crodjer
Last active February 14, 2021 09:38
Show Gist options
  • Save crodjer/8a79078a058db4afe0d74527efd29e30 to your computer and use it in GitHub Desktop.
Save crodjer/8a79078a058db4afe0d74527efd29e30 to your computer and use it in GitHub Desktop.
Raspberry Pi Cooling Test
#!/usr/bin/env bash
# A script to test the cooling performance of a RaspberryPi using `sysbench`
# Starts a syncbench process in the background and monitors the temperature.
#
# After the benchmark is complete, keeps the monitoring on to see how much time
# does the colling setup take to reach 55°C.
log () {
echo "$(date -Is)" $@
}
SECONDS=0
log "Starting benchmark..."
log $(vcgencmd measure_temp | cut -d '=' -f 2)
sysbench cpu --threads=4 --events=200000 --time=0 --cpu-max-prime=100000 run &
pid=$!
# Kill the sysbench when interrupted.
trap "jobs -p | xargs -r kill &> /dev/null" EXIT
while kill -0 $pid 2> /dev/null || test $(vcgencmd measure_temp | grep -Eo '[0-9]+' | head -1) -gt 56; do
log $(vcgencmd measure_temp) $(vcgencmd get_throttled)
sleep 2
done
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
log "...Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment