21.12 · Counting wake-ups: why polling costs energy even when the work is tiny
An idle phone sleeps deeply; every wake-up pulls the processor out of that state. Energy cost scales with how often you wake, not just how much work you do.
Mental model. Wake-ups can be counted from inside the process, and replacing a poll with a blocking wait or an event removes them.
Wake-ups
Measuring context switches and what removes them.
- Why does a tiny repeating poll drain the battery, and how can you count wake-ups yourself?
A processor in a deep idle state saves most of its power, and waking it costs a fixed amount of energy plus the time it needs to stay awake and fall back…
More in Performance & energy
- 21.1 · Measure first: the method, the metrics and the noise
- 21.2 · Instruments templates, signposts and XCTMetric
- 21.3 · MetricKit, Organizer and a performance culture
- 21.4 · SwiftUI invalidation and long lists
- 21.5 · The costs that show up in profiles: collections, strings, formatters, JSON, images and disk
- 21.6 · Energy: CPU wake-ups, timers, radios, location and thermal state
- 21.7 · App size: thinning, on-demand resources and the binary
- 21.8 · Writing benchmarks you can believe: the optimiser, build settings and growth tests
- 21.9 · Memory you can count: allocations, dirty versus clean pages and decoded images
- 21.10 · The main thread in code: hang watchdogs, actor hops and quality of service
- 21.11 · Launch: lazy initialisation and measuring from process start