Skip to content

Instantly share code, notes, and snippets.

Last active February 14, 2021 09:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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)" $@
log "Starting benchmark..."
log $(vcgencmd measure_temp | cut -d '=' -f 2)
sysbench cpu --threads=4 --events=200000 --time=0 --cpu-max-prime=100000 run &
# 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
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