All you need to know about energy metrics in software engineering

Status:: 🟩
Links:: Energy Carbon Intensity Measure energy consumption of software

Metadata

Authors:: Cruz, Luís; de Bekker, Philippe
Title:: All you need to know about energy metrics in software engineering
Date:: 2023
URL:: http://luiscruz.github.io/2023/05/13/energy-units.html
DOI::

Notes & Annotations

Color-coded highlighting system used for annotations

📝 Note (last modified: 2024-03-08#04:53:35) (

Blog post.


📑 Annotations (imported on 2024-03-11#18:55:17)

cruz.debekker.2023.energymetricssoftwareengineering (pg. 1)

Energy is often referred to as work: for example, in electricity, energy is the work required to move charged particles. The International System of Units (SI) defines joule (J) as the standard unit of energy. It is also the most common unit of energy used in scientific literature. Another common unit is kilowatt-hour (kWh). For example, it is used to report household electricity consumption. Kilowatt-hour represents the exact same parameter as joule but in a much higher order of magnitude. Kilowatt-hours can be easily converted to/from joules as follows:

1kWh=3,600,000J

cruz.debekker.2023.energymetricssoftwareengineering (pg. 1)

When measuring energy consumption, it is also common to talk about power consumption. Briefly, power represents the amount of work being done by a unit of time. For example, using standard SI units, 1 unit of power is equivalent to 1 joule per second. Instead of joules per second, we call it watts (W) in memory of the Scottish inventor James Watt.

cruz.debekker.2023.energymetricssoftwareengineering (pg. 1)

Using power units instead of energy units is useful in particular scenarios. Imagine that we want to measure the energy consumption of reading a book on a device. Saying that reading a book spends 10J does not say much about its energy efficiency – 2/9 the user could be reading for 1 minute or 10 minutes. In those cases, it makes sense to talk about power consumption.

cruz.debekker.2023.energymetricssoftwareengineering (pg. 2)

In a software project, energy consumption is usually the go-to parameter. We want to analyse the project by use case: for example, the energy consumption of applying a filter to a photo, uploading a file to the server, etc. Hence, as a rule of thumb, energy consumption is the parameter we should be reporting when testing energy in software projects. To compute energy consumption using power consumption, we need to factor in the duration of the execution.

cruz.debekker.2023.energymetricssoftwareengineering (pg. 2)

Given the average power consumption (Pavg), and the duration of the execution (Δt), the energy consumption (W) is computed as follows:

W=Pavg×Δt

cruz.debekker.2023.energymetricssoftwareengineering (pg. 2)

Energy consumption (W) is the integral of power consumption (P) over the interval of time needed ([t0,tn]) to execute a given software operation:

W=t0tnP(t)dt

cruz.debekker.2023.energymetricssoftwareengineering (image) (pg. 2)

Plot of power consumption over time. The area in gray is equivalent to the energy consumption between t=1st=1s and t=9st=9s.

cruz.debekker.2023.energymetricssoftwareengineering (pg. 7)

The carbon intensity is the amount of carbon dioxide equivalent that is emitted per unit of energy consumed. It is commonly measured in CO2eq/kWh or CO2eq/MWh. It is a useful metric to properly compare the carbon footprint of various energy systems and sources, as the energy consumption of a given system will vary depending on the power source.

cruz.debekker.2023.energymetricssoftwareengineering (pg. 8)

Note, carbon intensity can vary heavily due to several external factors. For example, the amount of CO2eq/kWh emitted differs substantially by the time of day and location due to the types of generation (wind, solar). When demand is higher than the existing power in the electricity grid, renewable-based power plants cannot adapt to demand and we need a power plant that is able to scale up to that demand. This is usually done by fossil-based power plants, also called marginal power plants. The problem is that marginal power plants do not scale down to zero. There is always a minimum carbon that needs to be emitted, even if there is a lot of renewable energy in the grid. Therefore, it is of key importance to account for the marginal carbon intensity: the increase or decrease in carbon emissions in the electrical grid, in response to an infinitesimal increase/decrease in power demand/supply.