Apple Profiling Tools – Shark is Out, Instruments is In

As we sat down today to do some performance profiling in Shark, we came to a sudden realization – it doesn’t work anymore with iOS4. After some quick Google searching I came across a thread in Apple’s developer forum (registration required) that indicated there were no plans to bring iOS4 support to Shark. What we have now is Instruments.

Instruments Icon

I’ll say it right off the bat – Instruments is better than Shark. It’s easier to use and easier to interpret the results. Shark always had a “dated” feel to it – probably because it’s a fairly old application now. Instruments has a much more cohesive user interface, allowing for simple switching between profiling a device, a simulator, or a desktop application.

Unlike Shark, getting Instruments to profile a device is a piece of cake. Once you launch it, you’ll be presented with a screen where you can choose the most typical profiling options.

Profiling Templates

Since we were interested in why a certain part of our application was taking so long, I chose “Time Profiler”, which will tell you where the CPU is spending most of its time.

The next thing you’ll have to do it select the application to target. You’ll want to go ahead and launch the application now. Since we’re working on Drop & Lock, I selected that.

Target Selection

All that’s left to do now is hit the big record button at the top to start and stop the profiler. When you’re done the results will be displayed much like any other profiler (including Shark).

Output

As you can see, most of our processing time is spent rendering the scene and might be a good place to start optimizing. An option that I found very helpful was “Show Obj-C Only”. This will remove items from the output that aren’t written in Objective-C. Since most of our app is written in Objective-C, this helps us find places in our code that can be improved. The option is located to the left of the results beneath the Call Tree options.

I haven’t had much time to see how powerful Instruments truly is, but at first glance, it looks to have a lot of capability. So if you app is running a bit slow, or using a bit too much memory, Instruments is a great tool for discovering why.

Leave a Reply

Your email address will not be published. Required fields are marked *