Here is a post on how to obtain energy measurements for different systems.
Some of the tools here are more fine-grained than others. Personally, I prefer using Perf to collect energy measurements from a running application. Perf is also using the RAPL interface and it is convenient for command-line users but is limited to Linux distros. With Perf you can measure any type of executable in the following way:
sudo perf stat -r 5 -e power/energy-cores/,power/energy-ram. ./executable
The above will give you an output of the energy consumption of the executable (can be any program written in Java, C, Python, and whatsoever). The -r 5
means that it will run the test 5 times to give you statistical results. However, this will give you the mean and not median results. Apart from the energy-cores
and energy-ram
you can get measurements from other components such as GPU baked on your processor.
Note that sudo
is required because perf is collecting measurements from machine-specific registers found in Intel processors. If you want to avoid using sudo
each time then run the following commands beforehand:
sudo sh -c 'echo -1 >/proc/sys/kernel/perf_event_paranoid'
sudo sysctl -w kernel.perf_event_paranoid=-1
Although you can use Perf to get energy measurements from many Linux distros, it is not supported for Raspbian (Raspberry Pi), yet.