Best way to benchmark iPhone app's battery usage? - ios

What's the best way to benchmark an iPhone app's battery usage?
I'm working on an iPhone app that uses location services and runs in the background. It seems like the battery drains significantly faster with it running, but when I try to do some structured tests, the results are inconclusive.
The steps I'm taking are:
charge the battery to 100%
remove the SIM (I need it for my other phone)
turn off push for mail/calendar/contacts
reinstall the app
restart the phone
start the app
return to SpringBoard (the app selection screen)
I then wait for about 15 hours and see what the battery is at. The results so far are:
App not running - 69% left
App running - 65% left
App running - 83% left

Turns out the answer is to use Apple's Measure Energy Impact in Xcode.
The info it provides really helped track down what was causing our battery draining issue.
In retrospect, I should have said that I was completely new to iOS, and was not a developer (working on the app as QA).

Doesn't that just tell you that there's not a high correlation between battery usage and your app running? It looks like there's something else that's causing battery drain?
(Watch out though, that something else might be the number of gps satellites passing at the time - the faster it gets GPS, the less battery usage your app will consume - you might have to take a look at how much time your app actually spends running vs sleeping for each test)

Related

Why does lag only stop after reboot?

When playing games on my phone for an hour the phone starts lagging quite a bit. Nothing I do takes away the lag except restarting the device. I have tried some memory cleaning apps on the playstore, I have tried cleaning all running apps, and I have tried apps that 'simulate' a reboot.
I also checked online and there are no adb commands that clear the RAM (I don't want to clear the game cache).
I am trying to find a way to stop my phone's lag the same way restarting it does, but there seems to be no info online at all. So what is happening when the phone is rebooting that cannot be done with software alone? If it is because the memory is being cleaned, why are there no apps that work?
This could be due to a lot of reasons, one of the main ones being thermal limits. Once you have been playing for a while, your phone might have to throttle it's performance to maintain a temperature safe for the SoC inside. I will say however, that cluttering your phone and background processes with a lot of these "memory cleaning" apps probably isn't helpful. If you are on android, there is a built in optimization widget (on new-ish devices) that you can free up ram and storage with.

My iPhone application project is taking more than 90% of battery usage

I have created a project which consists of coredata core location there is a lot of stuff doing with coredata my project is in final stage now I installed the application in my iPhone the battery usage is taking more than 90% is that a problem apple accepts it or not
This is really a critical issue if you app taking more than 80% of battery. After iOS 8.0 the OS will automatically kill your app if it will take such huge amount of device battery. So I don't think Apple will reject but this is not a good situation for any app user.

Prevent iOS app from deep sleeping efficiently

I'm building an alarm clock that allows the user to play a continuous sound at a specific fire date while the app is in the foreground and the screen is locked.
https://github.com/mruegenberg/MMPDeepSleepPreventer is the only solution I've found to prevent my app from exiting after 10 minutes. However, this approach is causing significant battery drain.
Are there any other approaches to this problem without draining the battery significantly? I know it is possible because there are other alarm clocks out there that do this without killing the battery and without jailbreak.

Will my heavy iPad app be rejected?

I am looking forward to submitting an iPad application which uses CoreAnimation a lot and so it's heavy.
In "App Store Review Guideline", it shows:
13.2 Apps that rapidly drain the device's battery or generate excessive heat will be rejected
While working my application on real iPad, it drains the battery to half in 4 hours, let the device to become a little bit warm. Will this be a reason enough to be rejected?

Instruments Energy Diagnostics -> Battery as percentage

I ran several long-term battery tests using Developer >> Logging for Energy Diagnostics. I've sent them all into instruments where I am able to determine the "Energy Usage Level". However, is it possible to also get the battery percentage at that moment instead of the "Energy Usage Level".
I was hoping to be able to graph the battery life percentage over time during the application running, along with determining when my application woke from sleep or turned on GPS.
The testing was done on an iPhone 4, iOS 5.0.1.
Powergremlin doesn't do exactly what you're looking for, but it is open source so might start you on the way to implementing it yourself.
Sadly, it is not possible. I ended up writing an application that would write to a database the percentage of the battery after a x time wait. It's a shame that apples own tool does not work that way :\

Resources