Profiling an iOS app

Profiling

While developing we often don’t care about the hard restrictions that we can’t overcome: hardware limitations, especially on mobile devices, always limit what we can do and what we should do.

This is not just true in regards to limitations of how many calculations we can achieve in a specified time, but also in respect to the user and his expectations. Imagine an app that drains your battery like it was a CapriSonne on a hot day. You would instantly remove it from your device.

To avoid those issues we use hardware monitoring and profiling to ensure a smooth quality of our apps and reduce resource hungry processes.

Profiling on iOS and Android differs in form of tools & procedure.

Profiling on iOS

To profile an iOS device just follow these simple steps to get a first insight in the hardware requirements for your app.

  1. Install XCode. Due to the gated environment for Apple devices we need to use XCode for any native iOS related stuff. You can simply get it on the AppStore on your Mac.
  2. Connect your iOS device via cable to your mac. Because we want to test real devices it wouldn’t make much sense to use the simulator, right? ;) Allow the connection on your phone when prompted.
  3. Start your app on your device as a release build. Because debug builds allocate extra memory for overrun detection and such, we want to avoid using any unnecessary overhead in our resource usage.
  4. Open Instruments from Xcode > Open Developer Tool > Instruments.
  5. A new window opens with all instruments available for you to use. For example we’d like to know how much CPU usage our app generates while in idle or usage. So we choose Time Profiler.
  6. On the up left corner of the Profiler window you’ll see a red record button as the first element. Next to it is a pause button and then you’ll see the process finder. When your phone is connected correctly you should be able to choose this device from the dropdown menu after hitting those button. Then you have to choose the correct process - your app - running on the device.
  7. Now you’re ready & set to get some live data from your device! Hit the record button and wait for your CPU usage graph to show up. :)

This is just a first introduction into the tooling used to profile an iOS app. There are a lot more instruments to be used and a lot more ways to process the raw data you get there. It might not tell you exactly ‘what’ is going rampage in your app, but it surely shows you ‘if’ there is a painpoint in resource usage.

comments powered by Disqus