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

Transcript

Your computer already knows which app is draining its power. Most developers never look at energy. They think it needs lab equipment. But desktop systems already estimate energy for each app. On a Mac, it is called Energy Impact. Windows has an energy estimation engine behind its power usage views. Microsoft and Apple build these energy meters into Windows and macOS. GreenCode's research review looks at tools like these. Here is the fix you can use today. Run your code, and open the Energy tab in Activity Monitor. On Windows, watch power usage in Task Manager. On Linux, try PowerTOP, or read the chip's energy counters with perf. Then compare two versions of the same task, using tools like GreenCode's green-languages. The difference matters more than the exact number. GreenCode helps tackle this by measuring energy before any change, and after every pass. A saving only counts if quality, security and errors did not get worse. That was GreenCode Tech Tip number sixty-one. Follow for the next tip, and find more on greencode.ai/tech-tips.

All GreenCode Tech Tips · All GreenCode videos

  • Tip #61
  • For Developers
  • Length 1:11
  • Category Measuring energy
GreenCode

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

Get in touch