Definition
Energy, for an electronic device, is the total electrical work that its supply delivers to it over an interval of time, measured in joules. Power is the rate at which that energy is delivered, measured in watts; 1 watt is 1 joule per second. Energy over an interval is the area under the curve of power against time, so it depends both on the length of the interval and on the power drawn throughout it. A timing measurement gives only the length, so timing alone cannot determine energy.
The idea
A radio exchange, one message sent and its reply received, can be made faster by running the processor at a higher clock frequency or by using more hardware in parallel. Both changes usually raise the power that the device draws while it works. Take two invented designs. Design A completes the exchange in 2 seconds at a constant 1 watt; design B completes it in 1 second at 3 watts. A latency plot shows B twice as fast. Yet A uses joules and B uses joules, so the faster design uses 1.5 times as much energy.
The reverse also happens. A faster design that draws only a little more power finishes sooner, lets the device return earlier to a sleep state in which it draws almost nothing, and can use less energy. Timing alone therefore does not even tell which of two designs uses less energy.
The picture to keep is an area. Plot power against time; the energy is the area under the curve. A timing measurement gives the width of that area. Its height comes only from a power measurement, and the height is rarely constant: a radio draws short bursts of high power to transmit and to receive, separated by long stretches of low power. The picture also shows why the window, the interval from a stated start event to a stated end event, must be named. A window that ends when the reply arrives leaves out the time the device then spends listening for further messages and going back to sleep, and that tail can hold much of the energy.
How it works
Measuring the energy of an operation takes six steps.
State the quantity. Name what is measured, such as the energy per completed exchange, and fix the window by its start event and its end event. Decide whether start-up, waiting, retransmissions §7.36 (messages sent again after a loss) and the return to sleep belong inside the window.
Choose the measurement point. A measurement at the supply input of the circuit board gives the energy of the whole board, including its voltage regulators (circuits that hold a supply voltage steady), indicator lights and sensors. A claim about one chip needs a measurement at that chip’s own supply connection.
Record current and voltage. The power at each instant is the voltage times the current. A common method passes the supply current through a shunt, a small resistor of known resistance, and measures the small voltage across it; the current is that voltage divided by the resistance. The supply voltage is recorded at the same instants, or held constant by a regulated supply and recorded.
Sample fast enough. A radio burst can last less than a millisecond. A meter that takes one reading every 10 milliseconds can miss such a burst entirely, so the interval between samples must be short compared with the shortest burst.
Mark the window in the same record. The device signals its start and end events, for example by switching an output pin that the measuring instrument records alongside the power samples, so that the events and the samples share one clock.
Add up and divide. Sum power times sample interval over the samples inside the window, then divide by the number of operations completed in the window.
When two designs are compared, everything except the design must stay the same; the answer at the end of this entry lists what to hold fixed. Attached equipment is easy to overlook. A debug probe, a device that connects a computer to a chip for debugging, can keep parts of a chip powered and raise the measured sleep power, and a logging connection that runs during the window adds power of its own, a form of instrumentation overhead §11.32.
Worked example
Two invented designs perform the same exchange on a device supplied at 3 volts. Design A is active for 4 milliseconds and draws 5 milliamperes. Design B is active for 2 milliseconds and draws 12 milliamperes. After the exchange, both keep the receiver on for 5 milliseconds at 6 milliamperes to catch a possible reply, and then sleep. Power is voltage times current. While active, A draws watt, which is 15 milliwatts, and B draws watt, which is 36 milliwatts. While listening, either design draws watt, which is 18 milliwatts.
One milliwatt for one millisecond is joule, one microjoule. The active energy of A is microjoules, and that of B is microjoules. B is twice as fast and uses times the energy.
The listening tail costs microjoules for either design. Over the whole window, A uses microjoules and B uses microjoules, a ratio of . A window that ends with the active part reports that B costs 20% more; a window that includes the tail reports 8% more. Both numbers are correct answers to different questions, so a report must state its window.
Failures change the result again. Suppose that one in every 10 exchanges by B fails once and is then repeated successfully, that A never fails, and that a failed attempt costs as much as a successful one. Ten completed exchanges by B then take 11 attempts, so B’s energy per completed exchange is microjoules, which is times that of A.
Stated precisely
Let be the voltage in volts and the current in amperes at one measurement point at time , in seconds. The power through that point is watts. The energy delivered through that point in the window from time to time is the area under the power curve. When the power is constant, . From samples of the power taken every seconds inside the window, the estimate is , where the hat marks an estimate. If operations complete in the window, the energy per completed operation is , with the energy of failed attempts counted in and the failed attempts not counted in . The average power is a finite-window rate §11.41: it describes that window only.
Compare two designs that each run at constant power, with powers and and durations and . Design B uses less energy exactly when , that is, when . A design twice as fast uses less energy only if it draws less than twice the power. A timing result supplies and says nothing about .
The estimate equals the energy of the stated quantity only if four conditions hold.
The right point. Voltage and current are measured at the same point, and that point matches the claim: the board supply for a claim about the board, the chip supply for a claim about the chip.
One clock. Voltage and current are sampled at the same instants, and the start and end events of the window are placed on the same time axis as the samples.
Fast enough sampling. The power changes little within one sample interval, so that no burst falls between samples.
A calibrated instrument with a known effect. The instrument’s error is known from calibration §11.42, and so is its effect on the circuit: a shunt of resistance carrying current lowers the voltage that reaches the device by .
Limits and common mistakes
Timing gives no energy result, and no battery-life result either. Battery life depends on the average current over the whole cycle of activity and sleep, which long sleep periods often dominate, and on the battery itself: many batteries, coin cells in particular, deliver less of their rated charge at high peak currents and at low temperatures.
Energy at the board supply is not the energy of one chip. Voltage regulators turn part of the energy into heat, and other parts of the board draw their own share.
An average hides bursts. Two power records with the same average can differ in peak current, and a peak can exceed what a small battery can deliver.
Energy per operation must include failed attempts. Dividing the energy of the successful operations alone by their number, after dropping the failed runs, reports less than the device spends. This is a form of survivorship bias §11.30: drawing a conclusion only from the cases that succeeded.
Questions answered
What should an energy experiment control?
An energy experiment should control, and report, everything that changes either the power the device draws or the length of time over which that power is added up, because energy is power accumulated over time. That means:
the window: its start and end events, and whether start-up, waiting, retransmissions and the return to sleep lie inside it;
the supply voltage, held constant and recorded;
the workload: the same messages, sizes and number of operations for every design compared;
the device state: clock frequency, enabled peripherals (on-chip hardware blocks such as timers and serial ports), sleep settings and temperature;
the radio conditions, such as distance and interference, which decide how many retransmissions occur;
the measurement path: the measurement point (whole board or one chip), the instrument and its calibration, the sampling rate, and one clock shared by the power samples and the markers of the start and end events;
attached equipment, such as a debug probe (a device that connects a computer to a chip for debugging) or a logging connection, which can draw power itself or keep parts of the chip powered;
failures, whose energy belongs in the total when the result is stated per completed operation.
A timing result controls none of the power side, so it cannot replace this measurement: a design that is twice as fast uses less energy only if it draws less than twice the power.
Related entries: Estimand and estimator (§11.2), Instrumentation overhead (§11.32), Calibration (§11.42), Finite-window rate (§11.41), Survivorship bias (§11.30).