Created
March 10, 2023 18:36
-
-
Save DanielGibson/6cb8cde302fb1d2658e6599b73fb84fa to your computer and use it in GitHub Desktop.
print current energy consumption of (AMD?) CPU every second, on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export LC_ALL=C | |
VAL=`cat /sys/class/powercap/intel-rapl:0/energy_uj` | |
while true ; do | |
# yes, this is probably not super-precise due to just using sleep and not measuring the time.. | |
sleep 1 | |
NEWVAL=`cat /sys/class/powercap/intel-rapl:0/energy_uj` | |
DIFF=$(($NEWVAL-$VAL)) | |
WATTS=`echo $DIFF/1000000 | bc -l` | |
printf "%.3f W\n" "$WATTS" | |
VAL=$NEWVAL | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment