Measuring a slow screen without guessing

Performance Senior Swift 5.0+ iOS 17+ Reviewed By Alok Singh

Pick the fix

Which first step avoids guessing?

Options
Hint 1 of 1

What tells you where time goes?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Add OSSignposter intervals for each phase, record on a device, and fix the largest phase

Correct. You see exactly where time goes.

Why not the others?
  • B Rewrite the screen in SwiftUI. It may not touch the slow part.
  • C Add caching to every request. It adds complexity without knowing the cause.
  • D Ask QA whether it feels faster. Feelings aren't measurements.

30-second answer

Define what slow means (for example time from tap to interactive), add OSSignposter intervals for each phase such as network, decoding and layout, and record them in Instruments on real devices. Compare with field data from MetricKit or your analytics. Fix the largest phase, then measure again against a budget and keep a performance test for it.

Practise saying it · 45 s. No recording, just a timer

Explain how you measure a slow screen.

Say your answer out loud, then check which of these points you covered:

  • Define the metric
  • Signposts per phase
  • Fix the biggest
  • Budget and test

Deep dive

Signposts show your phases alongside system activity.

Run requests in parallel if they don't depend on each other.

Prefetch what checkout needs when the cart opens.

Show content progressively instead of waiting for everything.

Signposted phase Type-checked · Swift 6.4
import os

let signposter = OSSignposter(subsystem: "com.example.shop", category: "Checkout")

func loadCheckout() async throws -> Checkout {
    let state = signposter.beginInterval("LoadCheckout")
    defer { signposter.endInterval("LoadCheckout", state) }
    async let cart = api.cart()
    async let methods = api.paymentMethods()
    return try await Checkout(cart: cart, methods: methods)
}

Common mistakes

  • Rewriting the screen before measuring.
  • Optimising the smallest phase.

Senior take & follow-ups

Seniors turn 'slow' into a number, find the phase, fix and verify.

Follow-up questions

Think of your answer first, then open the hint.

  1. How do you get field data?

    Show hint

    MetricKit, plus custom timing in analytics.

  2. What is a performance budget?

    Show hint

    A target time you test against.

Suggest a fix if something here is wrong or out of date.