Are there any tools or good techniques to find out where the performance bottlenecks are in an iPhone application?

巧了我就是萌 提交于 2019-12-25 18:19:55

问题


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?


回答1:


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:

  • "How do I profile how long a piece of code takes to execute in Objective-C/Cocoa for optimization purposes"
  • "How to reduce the startup time for a typical iPhone app?"



回答2:


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



来源:https://stackoverflow.com/questions/901308/are-there-any-tools-or-good-techniques-to-find-out-where-the-performance-bottlen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!