Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I think the title says Enough. For example Unity can generate you a report how much CPU/GPU power it's using or how fast it's going to drain device battery, but what about the applications developed using Cocos2d or the ones you develop directly using OpenGL? How should you profile them? In general what should you profile? or Should I simply run the application and wait for it's battery to run out?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

On the iPhone, you can go to Settings > Developer > Energy Diagnostics and turn logging on. You can then use the Energy Diagnostics template in Instruments to analyze the data from this log. It will break it down into several kinds of events and graph it over time, correlate it with CPU and network spikes, and generally work like any other Instruments session.

As far as I know (and I have looked, but not exhaustively) there is no equivalent tool for Android. There are some third-party apps that can sample battery across a long period of time to give you an idea of what the discharge curve looks like if you do choose to run your program for a long time. On shorter time scales DDMS can help you figure out some details like your general CPU usage and network usage, which you can then work on batching or reducing. But this is just general optimization help and a big step removed from detailed energy consumption data.

share|improve this answer
In the settings on Android there is a section for battery. It shows detailed information about your energy consumption and even which apps are using how much (given as a percentage of overall battery use). –  Amplify91 Sep 9 '12 at 18:15
@Amplify91: That's not present on some handsets which have OEM-customized settings apps. Even when it's there it's good for a very limited set of views (how much did I use in the past five minutes, how much did I use over the past 24 hours), none of which are good for telling you exactly what your program is doing to drain battery. It's like trying to use top for CPU profiling - it can sometimes tell you if you need to profile, but can't actually do it for you. –  user744 Sep 9 '12 at 20:17
yes, it is very bad for precise profiling, but as far as I have seen, I have never known a phone that didn't have it. –  Amplify91 Sep 9 '12 at 22:55

On Android you can:

  • use the Java API
  • build a linux kernel module or use the Linux kernel API
  • use the DDMS debugger ( that gives you an idea about the payload given by your application )

I do not know about iPhone, but since it's a closed platform and only uses Xcode for development, you probably only have this only one choice.

share|improve this answer
Use what Java API? Build what kernel module? Use DDMS to view what? This answer is useless and could vaguely describe how to collect data about anything. –  user744 Sep 9 '12 at 13:34
@JoeWreschnig the answer is not a tutorial, guess with what API you can do that? maybe with the battery related APIs? –  user827992 Sep 9 '12 at 13:43
Assuming you mean the ACTION_BATTERY_CHANGED Intent it's totally inappropriate for profiling (and also is generally buggy - barely appropriate for showing a battery % remaining with second-level precision! - and also your answer should at least link to it). Assuming you mean something else... well, then that's why you should write a better answer. –  user744 Sep 9 '12 at 14:17
@JoeWreschnig you probably know the english language worst than many other do on this planet. If you would be so kind to outline the part where i talk about intents ... –  user827992 Sep 9 '12 at 20:08
ACTION_BATTERY_CHANGED is "the Java API" for battery status on Android as far as I know, so if you don't mean that you don't mean anything. –  user744 Sep 9 '12 at 20:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.