iPhone 4 profile power consumption (with instruments)

Alex Stone picture Alex Stone · Oct 10, 2011 · Viewed 10.2k times · Source

I have an app that I added a lot of animation to. The app also used "iPhone sleep preventer" to play silent audio. Since then, I noticed that the battery consumption increased by up to 4 times! I'd like to find a method to profile the power consumption (I think I saw an option in Instruments) to find and eliminate the offending method(s).

Where would I start looking for information like this? Currently I have the phone left on the desk for ~3 hours to record power drain over time. Is there a better method to predict when the app will run out of power if running my app continuously?

An extra side question: are the % of battery left displayed in the status bar linear or is there some non-linearity towards the end of the battery life?

Edit: I found a "power" preset in xcode>product>profile>CPU>Energy diagnostics. It doesn't seem to work perfectly, as the power consumption level is always 0/20. But it does tell me how much of the CPU time is spent on app foreground, graphics and music!

Now I dont know how the CPU power is managed, is running the CPU at 75% more power consuming than lets say 30%? Intuitively it feels like it should...

Thank you!

Answer

Nuno Freitas picture Nuno Freitas · Oct 17, 2011

I'm no expert. Im fact I am only starting to power profile a iphone today, and looked upon your question here in hope off learning.

So I will share with what I've found in meanwhile. On IOS Developer Library I have found the following:

  1. Connect the device to your development system.
  2. Launch Xcode or Instruments.
  3. On the device, choose Settings > Developer and turn on power logging.
  4. Disconnect the device and perform the desired tests.
  5. Reconnect the device.
  6. In Instruments, open the Energy Diagnostics template.
  7. Choose File > Import Energy Diagnostics from Device.

And you have a report of Cpu and energy during the time of the log. You can find this steps and many more info on this section of the IOS Dev. lib.

I am still a bit fresh on this matter, so if you find anything that you think is meaningful please post that info here.

Edit: The apple dev lib suffered some changes. Updated link