Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode build settings for performance - iPhone apps

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

like image 492
Jugs Avatar asked Sep 25 '09 12:09

Jugs


2 Answers

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.

like image 199
bbum Avatar answered Sep 24 '22 00:09

bbum


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.
like image 41
Stephen Canon Avatar answered Sep 22 '22 00:09

Stephen Canon