21.2 · Instruments templates, signposts and XCTMetric

Instruments is a set of microscopes. The skill is not clicking record; it is picking the microscope that fits the symptom and marking your own code so the trace says what your app was doing.

Mental model. Match symptom to template, then add signposts so the timeline shows your intervals instead of anonymous stacks.

Choosing the instrument

Which template answers which question, and how sampling can mislead.

  1. Which Instruments templates do you reach for, how do you read a Time Profiler trace, and where can a sampling profiler mislead you? 21.2.1 · L3
    Pick the template from the symptom. Time Profiler answers “where is the CPU time going”: it samples every thread’s call stack at a fixed interval (about a…

Marking and testing

Signposts, Points of Interest and performance tests with XCTMetric.

  1. How do signposts and Points of Interest work, and how do you turn a measurement into an XCTest performance test with metrics and baselines? 21.2.2 · L5
    A signpost is a cheap, named mark in your code that Instruments draws on its timeline. Create an OSSignposter(subsystem:category:) (the category…

More in Performance & energy