Tech Tip #61: Your laptop already has an energy meter

Your operating system already knows which app is draining power.

Video created by explainapaper.com

The problem

Most developers never look at energy because they think it needs lab equipment. Desktop operating systems already estimate it per application: macOS shows Energy Impact, and Windows has its Energy Estimation Engine behind its power usage views.

The fix you can use today

  • Open Activity Monitor's Energy tab on macOS, or power usage in Windows Task Manager, while your code runs.
  • On Linux, try PowerTOP or read RAPL counters with perf.
  • Compare two versions of the same task, not absolute numbers.

Microsoft and Apple build energy meters into Windows and macOS. GreenCode's research review looks at tools like these.

Tools that help

  • green-languages (GreenCode researchers): a command-line tool that measures the energy of whole programs or marked sections of code, across languages
  • PowerTOP: shows which processes and devices wake the processor and use power on Linux
  • perf (RAPL counters): Linux perf reads the processor's RAPL energy counters, e.g. `perf stat -e power/energy-pkg/`

How GreenCode helps

GreenCode helps tackle this by measuring energy before any change and after every optimisation pass, on the same machines under the same load. A saving only counts if quality, security and error rate did not get worse. More on this.

Tags

#measurement#profiling#devices

Sources

All GreenCode Tech Tips

  • Tip #61
  • For Developers
  • Category Measuring energy
  • Format short video
GreenCode

Want this checked on your own system? Talk to the GreenCode team.

Get in touch