views:

1174

answers:

3

Hey Guys,

Is there any articles available online where can I find some tips on improving the iPhone application performance. I have read Apple docs on Memory Management and CPU cycles, but they are not very helpful.

Also can someone suggest a few XCode settings that could improve the performance of the application (release version)?

Thanks Jugs

+4  A: 

Short of measuring and optimizing, compiler optimization level is just about the only thing that will impact the performance of your application. Typically, you'll want an optimization level of -Os; that is, optimized code, but optimized for size, too. Since the iPhone's memory is limited, reducing code size is useful.

Beyond that, you are going to have to measure the performance of your application and react accordingly. There are many tools in Instruments and otherwise to help you in this task. The tools are actually pretty darned good, once you figure them out.

Given that you haven't actually measured anything yet (which is good -- make it work, make it right, make it fast), there may be low hanging fruit. Do you redraw something too often? Have some automatic timed event firing too fast? etc... Just don't fall into the trap of premature optimization; the need to measure & react is paramount to successful optimization.

Note also that you can do coarse grained optimization via the Simulator, but you really need to do the analysis on the app running on the device to do final polish optimization.


(1) Sounds like your database query is really slow. Not knowing the schema, etc, it is hard to know if that is truly the case.

(2) When doing performance analysis and the time is consumed by a function in an unknown library, look up the stack and see what is calling that library to figure out why your app is triggering the performance slowdown.

bbum
Thanks for your comments!My application is basically a UIKit application which asks the players a few questions and will then find out their compatibility. So it has several UI controls like UIButtons, UIPickerControl, UITextView etc.When the user selects a button, it takes upto 2-3 seconds for the app to respond eventhough it is just fetching a new question from the db which doesn't take much time. I tried various tools like Shark and Instruments and found where the CPU cycles are wasted and they are all in an Unknown library.Thanks
Jugs
+1  A: 

Basically, what bbum said. Get actual data and go from there. That said, there are a couple compile flags that can have substantial effect:

  • Make sure you aren't compiling at -O0. As bbum noted, -Os is probably what you want.
  • If you are doing a lot of floating-point computation, make sure that "Compile for Thumb" (-mthumb) is not set when building for ARMv6. The thumb instruction set on ARMv6 doesn't have floating-point instructions, so you hit a shim for every floating-point operation you use. Often this is offset by the code size savings, but if you have a lot of floating-point it can be a performance hazard. Note that you can build part of your project for thumb and part with it turned off. Also note that the thumb2 instruction set on ARMv7 supports floating-point.
Stephen Canon
+1  A: 

Best way to improve iPhone performance is to improve app performance, and not just through compiler optimizations, but through better algorithms.

Generally compiler optimizations may improve your performance by some single or two digit percentage. Code optimization using better algorithms, caching, re-architecting, etc. could have a three digit percentage improvement.

I've never found a compiler setting that noticeably improves my app's performance. Your miles may vary.

mahboudz