4

I've read about RAPL(Running Average Power Limit) in various different sites, but I'm still looking for an answer. I read that RAPL can measure the CPU energy consumption, or the entire system power consumption.

However, my question is: If I have a piece of code written in some language, such as MergeSort written in C, can I use RAPL to measure its energy consumption? Something like jRAPL is able to do, but not Java only. If yes, how can I do it?

Yaksa
  • 176
  • 1
  • 12

2 Answers2

3

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.

sgeorgiou
  • 59
  • 10
1

There is a recent project that allows that: https://github.com/hubblo-org/scaphandre

They also provide an example dashboard where processes and services consumption is isolated: https://metrics.hubblo.org

nulse
  • 862
  • 1
  • 8
  • 18