Re: smart fans
David Christensen wrote:
> For a CPU with N cores (N=4 for an AMD Ryzen 3 3200G?) and
> an otherwise unloaded system, your test procedure should be
> something like:
>
> loop over governor choices
> set governor
> loop 3 times
> sleep 60 seconds
> print statistics
> endloop
> loop from 1 to N
> start background process
> loop 10 times
> sleep 6 seconds
> print statistics
> endloop
> endloop
> kill all background processes
> endloop
>
> "print statistics" should include time, governor setting,
> number of background processes running, and CPU temperature.
> If would be nice to also include system loading percent, CPU
> frequency, and CPU fan speed.
Okay, what about
#! /bin/zsh
#
# this file:
# https://dataswamp.org/~incal/conf/.zsh/cpu
cpu-stats () {
local time=$(date +%s)
local gov=$(cpufreq-info -p | awk '{print $3}')
local back=$(jobs -l | wc -l)
local temp=$(sensors -j | jq -a '.["k10temp-pci-00c3"].Tdie.temp1_input')
local cores=$(getconf _NPROCESSORS_ONLN)
local avg=$(awk '{print $1}' /proc/loadavg)
local load=$(( $avg * 100/$cores ))
local freq=("${(@f)$(awk '/cpu MHz/{print $4}' /proc/cpuinfo)}")
local fan=$(sensors | awk '/cpu_fan/{print $2 " RPM"}')
echo "time ${time}"
echo "governor ${gov}"
echo "background processes ${back}"
echo "CPU temperature ${temp}C"
printf "system load %.1f%%\n" $load
echo "CPU fan speed ${fan}"
echo -n "CPU frequencies "
for f in $freq; do
echo -n "$f "
done
echo "MHz"
}
test-cpu () {
local cores=$(getconf _NPROCESSORS_ONLN)
local pids=()
local g
for g in $(cpufreq-info -g); do
sudo cpufreq-set -g $g
repeat 3 {
sleep 60
cpu-stats
}
repeat $cores {
perl -e '1 while 1' &
pids+=($!)
repeat 10 {
sleep 6
cpu-stats
}
}
done
for p in $pids; do
kill $p
done
}
--
underground experts united
https://dataswamp.org/~incal
Reply to: