1

I am working on an application for VoIP calls. Things seems to be going alright. I am concerned about the battery life. Even on Wifi battery seems to be draining very fast with an active VoIP call. Battery drain on Wifi is very quick, it would be faster over cellular data. What all steps can I take to improve the battery/power consumption? Also how can I profile/analyze the battery consuming processes in the app? Thanks in advance.

sole007
  • 716
  • 1
  • 10
  • 27

3 Answers3

3

Turning off the display can reduce battery usage while your app is running. If you need the display to be on, you can dim it by using:

[UIScreen mainScreen].brightness = 0;

If this isn't yet dim enough to reduce the battery consumption, you could maximize the dimming effect with wantsSoftwareDimming, though there could be a performance hit:

[UIScreen mainScreen].wantsSoftwareDimming = YES;

There could also be processes that are consuming a lot of battery due to intensive CPU usage. You can profile/analyze the battery consuming processes in your app using the Energy Diagnostics tool in Instruments described by Apple's developer resource. If you also add the Time Profiler tool to your list, you'll be able to match code execution up to power usage. The screen will look something like:

Instruments

Once you have identified the peak battery usage periods, you can relate those time frames to process activity. Investigate any heavy source code at these points and optimize them to reduce CPU impact. This may mean trimming functionality (i.e. reducing the real-time graphics animations or renderings).

Community
  • 1
  • 1
Ian MacDonald
  • 13,472
  • 2
  • 30
  • 51
2

A common misconception is that you need super fast updates or response times and so use the shortest timer duration possible (or none at all). Any modern processor saves most of its energy by going into a low power state during idle. The longer in idle, the deeper the sleep, the more power savings.

A classic example is monitoring the keyboard or mouse for an event. A human being can't react faster than .25 seconds, but people use sleep intervals of <10 msec (or none at all) under the mistake belief that'll result in better performance/response. But doing so keeps the processor awake and consuming energy while not contributing to the application's response time.

Ideally, you want to use the largest sleep duration between periods of activity while still have good performance. This means you have a cost trade off. I usually try to hit 85% to 95%, depending upon the needed response time. This gives the processor time to drop into a lower power state, dropping my energy usage rate dramatically.

I recommend the following: (1) calculate an 85% or 95% no defect situation, (2) test the quality and tweak the idle period down (better response) until you have the minimally acceptable quality, and (3) use that interval.

Taylor Kidd
  • 1,463
  • 1
  • 9
  • 11
1

A good place to look is: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/PerformanceTips/PerformanceTips.html

Apple sets out a number of workarounds for common battery consumptive tasks such as Long Polling, common read-writes, etc.