iPhone 4 profile power consumption (with instruments)
Asked Answered
J

1

15

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!

Jalisajalisco answered 10/10, 2011 at 15:29 Comment(3)
I don't know about power profilers, but I would suspect that playing "silent audio" is contributing. I believe the phone will normally power down its audio amplifier circuits, and this would cause them to be powered all the time. Also, is the display backlight kept on? That is probably the single hungriest component in the phone.Richey
the screen is kept on for accelerometer purposes. I'm getting widely varying power consumption results. In some cases it seems the phone may run for 8 hours, in some for only 5. that is starting with 100%Jalisajalisco
This could be due to auto adjusting brightness at different times of the day and illumination levelsJalisajalisco
H
33

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

Hornwort answered 17/10, 2011 at 14:50 Comment(6)
Nuno, that's a great find, exactly what I needed! ThanksJalisajalisco
To save future readers from confusion, it took me a few minutes to find the paragraph from the link above: "Note: The Energy Usage instrument is currently supported in the iPhone 3GS and the third-generation iPod touch."Extremity
Can anyone share some info on how to anylize the dataBilberry
@Extremity is there any way to distinguish and filtered collected report for my app only? ( even I chose the target it doesn't matter and show the whole report! I want to check the GPS usage but only for my appRallentando
@MoFarhand I'm not developing iOS apps anymore, but "in my days" this was not possible. I would just kill or restrict Location access to literally everything else than your app on your testing device.Extremity
@Extremity Thank you, just wanted to make sure there is nothing that I missed in the instrument or configuration.Rallentando

© 2022 - 2024 — McMap. All rights reserved.