简体   繁体   中英

How to find performance bottlenecks in an iPhone app?

I feel my app has bad performance, and want to figure out which parts in code are evil. Is there a good tutorial somewhere on how to find these?

Instruments is your friend in this regard, and has many excellent profiling tools for finding memory leaks, how much memory you're using, detailed tracing of what code is running when, and so on. You can find the Instruments User Guide here .

However, you should also look into a little tool called Shark, installed with the developer tools. Personally, I find Shark more useful than Instruments for profiling my code and finding out what's taking up time when it matters. Read Optimizing your Application with Shark 4 for lots of great info on using Shark.

I've just spent a few days optimising my iPhone app, and Shark is a wonderful tool. Once you find out where you're slow, making it fast can be quite difficult, especially if you're drawing UIImages — expect to do a lot of caching of images into static variables!

Optimising can really reduce the readability of your code, so make sure you're careful where you do it and that it's absolutely necessary.

Do some profiling using the "Instruments" app found in the same directory as XCode.

You can run you program with Instruments by using "Start with Perfomance Tool" in XCodes "Run" menu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM