Green Metrics Tool helps developers measuring & optimizing software power consumption

The Green Metrics Tool (GMT) is an open-source framework that allows the measurement, comparison, and optimization of the energy consumption of software with the goal of empowering both software engineers and users to make educated decisions about libraries, code snippets, and software in order to save energy along with carbon emissions.

While the firmware of battery-powered embedded devices and the OS running on your smartphone are typically optimized for low power consumption in order to extend the battery life, the same can not be said of most software running on SBCs, desktop computers, and servers. But there are still benefits of having power-optimized programs on this type of hardware including lower electricity bills, a lower carbon footprint, and potentially quieter devices since the cooling fan may not have to be turned on as often. The Green Metrics Tool aims to help in that regard.

The developers explain how that works:

Any application will be containerized and then analyzed by its logical parts. The open-source tool measures classical performance metrics as well as energy-related metrics like wattage, temperature, and cooling efficiency to understand what part of the software is responsible for which part of the energy consumption.

Through the concept of usage scenarios, we create an interface for developers to test/develop against. In the end, this makes complex software products comparable to each other and thus enables developers to select libraries based on their functionality-energy-profile (for instance messages per Watt or similar).

Green Metrics Tool requires a Linux host, and it looks interesting enough, so I tried to install it on Ubuntu 20.04 and 22.04 . I followed the installation instructions starting on my laptop running Ubuntu 20.04 with the following command installing some dependencies:

The next step was to install Docker:

We can verify docker is installed and running properly by typing:

It will output a view with container-id, name, and stats, which are all empty for now.

Docker stats

I had to run the command with sudo, but GMT is designed to work only with Docker in rootless mode, and I had to install a few more packages:

It ends with:

So I edited ~/.bashrc accordingly by adding the two export lines.

Lastly please run the following commands to have the docker daemon always lingering:

cgroup2 support must also be enabled. It is enabled by default in Ubuntu 21.10 and greater, but since I’m still on Ubuntu 20.04, I had to enable it manually along with CPU, CPUSET, and I/O delegation as explained on To enable cgroup2, I had to create the file /etc/default/grub.d/50-cloudimg.settings.cfg with the line:

Then update the grub configuration with:

To enable the delegation, I had to run a few more commands:

Once this is done, I had to reboot my computer and could verify everything is setup as expected:

The last step was to run the install script to configure the database, create a few files, install even more dependencies, and build the Metric Providers:

I had a couple of errors: “g_string_replace” undeclare and the sgx binaries would not build because the directory is empty. The first error only happens in Ubuntu 20.04, and not Ubuntu 22.04, and it looks like it may be a new function in glibc, and the second happens in both, so I just comment that part out to complete the build. We can now run the Docker container with:

It took around 20 minutes to build the docker image and I can now access the dashboard at

The Green Metrics Tool supports various Metric Providers in C or Python that measure power consumption (powerstat), report various CPU usage metrics, gather data for lm-sensors, leverages the Running Average Power Limit (RAPL) interface for CPU and memory energy usage, and so on.

Green Metrics Tool Dashboard

The Green Metrics Tool supports various Metric Providers in C or Python that measure power consumption (powerstat), report various CPU usage metrics, gather data for lm-sensors, leverage the Running Average Power Limit (RAPL) interface for CPU and memory energy usage, and so on.  But after looking into GMT documentation the learning curve may be longer than I initially anticipated, and I noticed a public demo is already running with various tests available. So let’s check out the output from the first project: “Fujitsu TX1330 M2 – Stress-Interval with powerspy”.

Green Metrics Tool Stress Interval PowerspyWe can see some information about the project and its duration, and if we scroll down we have widgets with various “system level metrics” followed by compound metrics.

GMT CPU Utilization Memory Power Usage

Scrolling further we have a range of charts for each metric such as the CPU energy usage over time.

Green Metrics Tool Chart

Analysing the data also requires some expertise and time to learn, and if you want to check some practical results, the developers have written about a few case studies with different image file formats, WordPress vs Hugo, etc… If your software is located in a public repository on GitHub and you’ve done some optimizations, it will eventually be certifiable based on various schemas such as Green-Coding-Berlin, Blue Angel (Blauer Engel in German) and SCI from the Green Software Foundation.

You’ll find the source code of the experimental software and more details on the GitHub repo. You may also want to attend Arne Tarara’s FOSDEM 2023 presentation entitled “Green software engineering” where he will give an overview of the tool and present the roadmap with eventually the goal of having “a public and open database of energy information for arbitrary hardware setups, code blocks, and libraries and a green standard library/green code completion”.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard
Notify of
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
1 year ago

“Green Software” is bullshit, most of the CO2 emissions are in the production of hardware, not in the electricity consumed by the devices.

Upgrade pi-top [3]
Upgrade pi-top [3]
1 year ago

You can lead a horse to water but you can’t make it drink…

1 year ago

Excellent overview, I’ll try as soon as possible! Actually I daily use Scaphandre to track servers and applications power consumption :
I agree CO2 is not a good metric, only Watts matter, because depending of the country you host your application CO2~Watts is different!

1 year ago

> only Watts matter

And I already wondered how this could be measured with this ‘Green Metrics Tool’ on HW that lacks any such measuring capabilities. Turns out just as with Scaphandre this is blindly trusting into software –> powercap/rapl

“RAPL is not an analog power meter, but rather uses a software power model. This software power model estimates energy usage by using hardware performance counters and I/O models”

Jean C.
Jean C.
1 year ago

Intel: “RAPL is an interface for reporting accumulated energy consumption of various system-on-chip (SoC) power domains.” As stated here there are power monitoring circuits in the machine, it’s not an out-of-air estimation 🙂 RAPL uses hardware probes and is actually very accurate (tested with a powermeter). One must not forget that it only provides partial results, e.g. it does not include cooling, but apart from that it’s actually quite good! Note that on recent hardware it gives more information (i.e. there are more components that are monitored), for instance on my laptop there’s a RAPL domain that coincides with the… Read more »

Khadas VIM4 SBC