views:

177

answers:

2

I have an app that's half way done. The performance is not really good, and I wonder where the bottlenecks are. Although I can go ahead and start commenting out suspected lines of code, I wonder if there are any tools that would tell me which method cool took how long and what happened next. The stack trace isn't really that helpful.

I had a weird idea to convert the stack trace into an GraphViz graph, to see visually the whole picture. I know some guys at IBM did something similar that generated an visual graph of the stack trace, which was very impressive and meaningful. Before I reinvent the wheel: Is there some good tool or technique that helps finding performance bottlenecks on iPhone OS?

A: 

Use Instruments (an application shipped with the developer tools) to attach to the process and measure performance.

There's a preset entitled "Core Animation," which is probably what you want.

There's a tutorial video on the iPhone Developer portal on Instruments: http://developer.apple.com/codingheadstarts/index.html

Kenneth Ballenegger
+2  A: 

As Kenneth said, Instruments in an invaluable tool for performance optimization of a Cocoa application. Its user guide can be found here (or in your Xcode documentation). One of the great things about the Xcode debugging tools is that they can be run against an application executing on the device, so you can use Instruments to do profiling of your application on the actual hardware.

When using Instruments, I've found that the CPU Sampler tool can give a very good breakdown of where my application is spending the most time. For example, I had what I assumed to be a slow SQLite query and was gearing up to optimize all my SQLite interactions when I ran Instruments and found it to actually be due to some wasteful string processing routines.

You can also use Shark for profiling, although it's not as easy to use.

You may also be interested in the answers to these questions:

Brad Larson