5 Simple Steps to Find Slow Code Using Xcode Time Profiler

It is easier than you think

Lee Kah Seng
6 min readJun 6, 2023

This article is originally published at swiftsenpai.com

Xcode Time Profiler is a powerful performance analysis tool provided by Apple. It is specifically designed to help developers optimize the performance of their iOS, macOS, watchOS, and tvOS applications.

If you open the Time Profiler for the first time, you might feel overwhelmed by its complex user interface and the abundance of data presented to you. To assist you in getting started, here are five simple steps you can follow to identify the bottleneck in your code:

  1. Profile Your App
  2. Filter the Track Viewer
  3. Simplified the Call Tree
  4. Analyze the Heaviest Stack Trace
  5. Reveal Source Code in Xcode

Now, let’s go through these steps one by one, shall we?

The Sample App

To demonstrate the capabilities of the Time Profiler, I have created a sample app exclusively for this article. This app features a single button that, when tapped, loads two text files repeatedly for a total of 1000 times.

@IBAction func loadFiles(_ sender: Any) {

for _ in 0..<1000 {…

--

--