Skip to content

Instantly share code, notes, and snippets.

@adionditsak
Last active October 21, 2024 09:27
Show Gist options
  • Save adionditsak/b636a4db0509a9c940638863facb1198 to your computer and use it in GitHub Desktop.
Save adionditsak/b636a4db0509a9c940638863facb1198 to your computer and use it in GitHub Desktop.
Calculate milliwatt per second in Debian
sudo -v; old_energy_uj=0 old_time=0; while :; do energy_uj=$(sudo cat /sys/class/powercap/intel-rapl/*/energy_uj); time=$(date +%s%N); echo $(( (energy_uj - old_energy_uj) * 1000000 / (time - old_time) )); old_time=$time old_energy_uj=$energy_uj; sleep 1; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment