commit a1ab7a1b519dcedd00cb53a05dc0ae7435739762
parent 7a6a5f84891413347d7cf2d9a13a9b387a4a94e0
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 1 Oct 2020 09:25:08 +0200
temptest: calculate average cpu frequency on linux
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/.local/bin/temptest b/.local/bin/temptest
@@ -20,6 +20,16 @@ get_temp() {
get_speed() {
if [ "$(uname)" = OpenBSD ]; then
sysctl -n hw.cpuspeed
+ else
+ awk '
+ {
+ if (match($0, /cpu MHz/)) {
+ avg += $4; n++
+ }
+ }
+ END {
+ print avg/n
+ }' /proc/cpuinfo
fi
}