21.6 · Energy: CPU wake-ups, timers, radios, location and thermal state
A phone’s battery is spent on a few things: the screen, the radios, the CPU waking up, and the GPS. Most app energy problems are the same mistake: doing work at times the system would rather stay asleep.
Mental model. Energy is power × time. Do less work, do it in batches, and let the system pick the moment when you can.
Where energy goes
CPU, timers, networking, location and the display.
- Where does an app’s energy go, and how do timers, networking, location and animation change the battery bill?
The big spenders are the CPU and GPU (sustained work, and especially waking from idle again and again), the radios (cellular and Wi-Fi), location (GPS, high…
Adapting
Low Power Mode, thermal state, background work and the tools.
- How should an app respond to Low Power Mode and thermal pressure, and how do background work and the tooling fit in?
The system tells you when to back off. ProcessInfo.processInfo.isLowPowerModeEnabled says the user has asked to save battery (observe…
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.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
- 21.12 · Counting wake-ups: why polling costs energy even when the work is tiny