Performance investigation starts with a reproducible symptom and a representative workload. Static patterns point to possible problems; runtime measurements establish whether the change helps.

Reproduce workload → Record baseline → Change one cause → Compare trace
  1. 1Reproduce workload
  2. 2Record baseline
  3. 3Change one cause
  4. 4Compare trace

Work through the example

Separate cold launch, warm launch and interaction responsiveness. Record device conditions alongside measurements.

Start with a disposable branch and synthetic data. Write the expected outcome before changing the implementation, then keep the first failing result. This prevents a later repair from quietly redefining the task. The procedure below is grounded in the repository reference; its examples must still be checked against your project and installed toolchain.

Implementation reference

The following focused section is adapted from the maintained project guide. It preserves the source’s examples and limitations.

Instruments Profiling

Time Profiler

  • [ ] Profile the app with Time Profiler to find CPU hot spots
  • [ ] Look for methods consuming >10% of total CPU time
  • [ ] Check for work on the main thread that should be on a background queue
  • [ ] Verify no synchronous I/O (file reads, database queries) on the main thread
  • [ ] Identify redundant or repeated calculations that can be cached
How to run: Xcode > Product > Profile > Time Profiler
Focus: Check "Hide System Libraries" to see only your code
Tip:  Use Call Tree > Invert Call Tree to find leaf functions consuming the most time

Allocations

  • [ ] Profile with Allocations to track memory growth over time
  • [ ] Check for unbounded memory growth during scrolling or navigation
  • [ ] Identify transient allocations that could be reduced (e.g., creating objects in tight loops)
  • [ ] Look for large allocations (images, data buffers) that are not released
How to run: Xcode > Product > Profile > Allocations
Focus: Mark Generation snapshots before and after user flows to isolate growth
Tip:  Filter by "Persistent" to find objects that never get deallocated

Leaks

  • [ ] Run Leaks instrument to detect retain cycles
  • [ ] Investigate any leaked objects (especially closures capturing self)
  • [ ] Verify delegates are declared weak
  • [ ] Verify closures use [weak self] when capturing view models or coordinators
  • [ ] Check Combine subscriptions are stored and cancelled properly

Network (Instruments)

  • [ ] Profile network calls with the Network instrument
  • [ ] Identify redundant or duplicate API requests
  • [ ] Check for requests that could be batched or deduplicated
  • [ ] Verify responses are cached appropriately (HTTP cache headers)

Animation Hitches (Core Animation / RenderServer)

  • [ ] Profile with the Animation Hitches instrument
  • [ ] Target zero commit hitches (frame drops during layout/render)
  • [ ] Target zero render hitches (GPU cannot complete frame in time)
  • [ ] Investigate any hitch duration > 8ms on 120Hz devices

Acceptance and failure review

Checkpoint What to inspect If it does not match
Reproduce workload Confirm the input and environment Preserve the failure and return to this step
Record baseline Inspect the intermediate artifact Preserve the failure and return to this step
Change one cause Run the focused check Preserve the failure and return to this step
Compare trace Record the observed result Preserve the failure and return to this step

Ask the agent to explain the smallest change that resolves the observed mismatch. Keep unrelated refactors out of the repair. A change that makes a warning disappear is not enough if the behavior or ownership contract has changed. Re-run the same acceptance check so the before and after results are comparable.

Evidence and limits

No invented launch-time or hang-rate numbers are supplied.

This is an educational guide. Its presence in the series does not certify a completed client-specific lab. The series evidence record separates executed checks from exercises and blocked environments.

Inspect the source used in this lesson.

What to do next

Next: Memory: retain cycles agents create in closures and Combine