21.1 · Measure first: the method, the metrics and the noise

Performance work is mostly about not fooling yourself. A change that feels faster, on a simulator, in a Debug build, once, proves nothing. The method is what keeps you honest.

Mental model. Never change code until you have a number, a way to reproduce it, and a profile that points at the cause. After the change, take the same number again.

The loop

Reproduce, measure, profile, change one thing, measure again, and know which kind of problem you have.

  1. How do you approach a performance problem, and which kinds of problem are there? 21.1.1 · L2
    Work in a loop and do not skip steps: 1) reproduce the problem on a stable scenario (a script, a UI test, a fixed data set), 2) pick one metric that defines…
  2. How do you measure performance reliably: what makes numbers lie, and why do percentiles beat averages? 21.1.2 · L3
    Measurements lie for boring reasons. Debug builds are unoptimised, so Swift code can be many times slower than the Release build users run. The simulator uses…

More in Performance & energy