AI Agents change how we develop, and you might think you no longer need Xcode Instruments for performance iterations. When I started developing apps in 2009, we would constantly use Xcode Instruments’ Time Profiler and other instruments to analyze and improve our apps’ performance. Devices were simply much slower, so if you didn’t do it, your apps would die due to memory usage.
Nowadays, we have blazing-fast devices. It feels redundant, and it’s true: it’s less needed. However, I truly believe we can make our apps so much better and more performant if we visit Xcode Instruments regularly. The good news is that you don’t have to do the analysis yourself anymore: AI Agents can help.
In short: record your reproduction path with the Time Profiler and a signpost instrument, copy the results into a prompt, and let your agent propose the next optimization. I used this flow to make RocketSim’s accessibility elements fetching 25 times faster.
If you’re new to Instruments, start with my Xcode Instruments guide. This article builds on it.
Sample Case: 25x faster accessibility elements fetching

AI Agents are great at performance iterations. You can ask them to set a baseline and constantly compare the new results against it. It’s also smart enough to revert changes if they didn’t bring the expected results.
RocketSim’s CLI allows agents to fetch accessibility elements from the Simulator. Agents use them to navigate the Simulator app autonomously. When I started my performance improvements, I had two problems:
- Accessibility elements were missing (e.g. Tab Bar items)
- Fetching elements was terribly slow
As soon as I fixed the first point, fetching became even slower. Fetching took ~12.18 seconds for a screen with 70+ elements. If an agent has to navigate the Simulator, spending 12 seconds per step, it would be a waste of time.
I won’t go into the specifics of what I changed to improve the code, because it will not be applicable to your app. What I can tell you is that I used Xcode Instruments to give AI eyes, allowing it to analyze the code deeply and identify where to make improvements.
Overall, the phases improved like this:
- Phase 1: 12s → 4s (3x)
- Phase 2: 4s → 2.5s (5x)
- Phase 3: 2.5s → 525ms (23x)
- Phase 4: 525ms → 485ms (25x)
It’s tempting to stop at phase 1, because you would think AI has already done everything it could to speed it up. However, it’s crucial to keep iterating, as new results reveal additional performance improvements.
Adding a CLI to your app
Before we dive into how I use Xcode Instruments and its Time Profiler to give AI insights into your app’s performance, I first want to recommend adding a CLI to your app. Not for production use cases, but for giving your agents an easy way to verify improvements.
I added RocketSim’s CLI for production reasons, not realizing I’d also made my development workflow much better. I could suddenly ask my agents to improve the performance of RocketSim features by making the same features available in the CLI. The agent applies improvements, runs the CLI, and compares the outcome.
Note that the performance of your CLI isn’t the same as the in-app performance, but it does isolate performance benchmarks for the specific methods used in your app.
How to use Time Profiler with an AI agent
It’s important to know that a CLI alternative exists for Xcode Instruments:
avanderlee@AJs-MacBook-Pro ~ % xctrace help
usage:
xctrace <command> [options]
global options:
-q, --quiet
commands:
record Perform new recording using specified template
import Import file of a supported format into .trace file
export Export .trace file content to an external format
remodel Remodel .trace using currently installed modelers
symbolicate Symbolicate .trace file using specified dSYM
list [devices|templates|instruments] List capabilities of the current running environment
version Print version of the tool
further help:
xctrace help <command>
Reading raw xctrace output quickly eats your tokens, though. That’s why I built RocketTrace, which I’ll get to below. Manually using Xcode Instruments might still feel better if you’re used to it, so let me first show you the manual flow.
My flow looked as follows:
- Apply the performance improvements to the agents
- Re-run the app inside Xcode Instruments with the Time Profiler template and an additional signpost instrument
The latter allows you to provide more specific insights to your agents. By adding signposts, your code becomes visible in the signpost instrument:

Of course, you can ask the same agent to add those signposts.
The image above shows that I ran multiple times. These runs represent the different phases I mentioned earlier. The four blue bumps in the signpost graph represent me using RocketSim’s accessibility overlay to fetch the elements four times.
Once done, I would collect the information for the agent:
- I switched from List: Metadata to List: Intervals, selected all rows, and copied them to the clipboard
- I then selected the Time Profiler instrument for the same time range and made a deep copy of the root element
The latter looks as follows:

Note that I used the Call Tree filter in the footer to:
- Separate by Thread
- Hide System Libraries
This way, you reduce the output to what matters.
Creating the prompt
Combining both outputs allows you to create a follow-up prompt. I used something like:
I tested the functionality 4 times. Here are the signpost intervals:
<signpost_intervals>
And here are the Time Profiler insights:
<time_profiler_deep_copy>
Analyze and create a new plan for further optimizations.
That would be enough for the agent to analyze the results and propose the next phase of improvements.
Consider your token usage
The above prompt is far from optimized for token usage. Occasionally, I would skip the signposts and shared the time profiler deep copy first. It’s often enough already to come up with performance improvements.
At the same time, the raw output of the deep copy can be significantly optimized. It looks a bit like this:
Weight Self Weight Symbol Names
2.02 s 100,0% 0 s RocketSim (13637)
642.00 ms 31,9% 0 s RocketSim (0x2daf767)
635.00 ms 31,5% 0 s partial apply for closure #1 in AccessibilityElementsCoalescer.accessibilityElements(deviceUDID:)
635.00 ms 31,5% 0 s closure #1 in AccessibilityElementsCoalescer.accessibilityElements(deviceUDID:)
635.00 ms 31,5% 0 s protocol witness for AccessibilityElementsFetchProvider.fetch(deviceUDID:) in conformance SharedSimulatorAccessibilityFetchProvider
While it’s not bad, it can definitely be optimized a lot. That’s exactly what I built RocketTrace for.
Let RocketTrace do the analysis
RocketTrace replaces the copy-and-paste part of the flow above. It records your app or imports a trace you already have, and ranks what it finds by measured impact. Your agent gets the evidence in a format built for it, instead of a raw deep copy.

You can hand the results to your agent in two ways:
- Agent Prompt: every finding comes with a prompt that packages the evidence, the impact, representative frames, and source-search terms. You paste it into any coding agent.
- CLI and Agent Skill: RocketTrace installs a
rockettracecommand and an Agent Skill, so your agent can run the whole flow itself.
With the CLI, the flow I described earlier becomes this:
rockettrace record start <build-id> --label "Fetch elements"
# Run your reproduction path in the Simulator, manually or driven by your agent
rockettrace record stop --wait
rockettrace results get <result-id> --brief --format compact
The compact format uses roughly half the tokens of the classic JSON output, and the Agent Skill knows how to read it. That’s exactly what I was missing when I copied deep copies into prompts.
It also makes the phases from my sample case a loop. Record a baseline, let your agent apply a change, record again, and compare both results with rockettrace results compare. You can read more in the CLI and Agent Skill documentation.
Iterate and improve
The above cycle was repeated for every optimization phase. Eventually, the performance was good enough to stop considering another iteration. An agent will likely tell you as well: there is no way to make your code faster than this.
Frequently asked questions
Yes, in two ways. xctrace is the command line version of Instruments, and you can also copy signpost intervals and a Time Profiler deep copy into a prompt. RocketTrace automates this with Agent Prompts and a CLI and Agent Skill, so your agent can record and read traces itself.
Select the Time Profiler instrument for your time range and make a deep copy of the root element. Separate by thread and hide system libraries first, so the output only contains what matters. Paste it into a prompt, together with the signpost intervals if you have them, and ask the agent to analyze it and plan further optimizations.
A CLI gives your agents an easy way to verify improvements. The agent applies a change, runs the CLI, and compares the outcome. The performance of your CLI isn't the same as the in-app performance, but it does isolate benchmarks for the specific methods used in your app.
Share the Time Profiler deep copy first and skip the signposts, as that is often enough. The raw output can still be optimized a lot. RocketTrace's compact format uses roughly half the tokens of the classic JSON output.
Conclusion
Xcode Instruments Time Profiler can be a great way to optimize your code using AI agents. By creating a performance optimization plan based on a deep copy prompt, your agent will be able to connect the project’s code to actual performance insights and improve accordingly. Repeating this flow can yield significant performance gains, and RocketTrace takes care of the copying so your agent can iterate faster. If you want to know more about the fundamentals of Instruments itself, read my Xcode Instruments guide.
These workflows are just the beginning and a subset of what I’ll train in my dedicated course. I’d love to welcome you to it: Agentic coding fundamentals for developers.
See you there?


