Explain the statistics of Energy Usage Instrument in iOS - ios

I am trying to find Energy Usage for my iOS App using Instrument.
I got the statistics like Time, Total Activity, Foreground App Activity, Audio Processing and
Graphics in Percentage format. The sum of Foreground App Activity, Audio Processing and
Graphics is different from Total Activity !
But I am not understanding what are the meaning of these columns? Can anybody please explain me the meaning of these statistics and how to use this?

Latest Energy Diagnostics documentation says:
The Energy Usage instrument shows a level from 0 to 20, indicating how
much energy your app is using at a given time. These numbers are
subjective. If your app’s energy usage level is occasionally high, it
doesn’t necessarily mean that your app has a problem. Your app may
simply require more energy for some of the tasks it performs. For
example, it may use GPS while performing complex network operations.
This is valid energy use. What you should look for are spikes or areas
of high energy use that are unexpected or that could be performed at
more optimal times.

yes, sure there is difference. The best way to use it; do one at a time. observe each Activity Consumption and target optimizing that.

Related

Battery impact of keeping microphone on while in-app

I've been looking around for a while but couldn't find much about this. I have an AudioComponentInstance that I use to continuously record the user while in-app. This doesn't get written to a file, but I do some light processing in a recording callback. This light processing is basically an offline, lightweight voice activity detection system on every 100ms of audio data.
So essentially what I have is like the Hey Siri feature. While in-app, the microphone is always on. It waits for the user to start talking, and once the lightweight recognizer detects speech, other stuff happens.
I know this can be very battery efficient because Hey Siri is a system-wide feature. But at the same time, I have no clear idea of the impact on battery life. I only have anecdotal data – for example, the Sleep Cycle app uses 30% of battery if your phone is not charging while you sleep. So in that case, 30% battery for 8 hours of mic use. But that might be high because they're constantly doing some sort of sleep processing?
Is there a way to use Instruments or something to do an isolated battery test, or someone who has a better understanding of the microphone's impact on battery life? Thanks!
In your case, using "Hey Siri" as a comparison is not accurate because this feature relies on a dedicated SoC, specifically to optimize power usage. In your scenario, you have no choice but to consume CPU resources which will result in a higher power draw.
While further testing would be required, my assumption is that your power usage will be no better than an app in idle state at best (YMMV based on what else your app is doing).
https://machinelearning.apple.com/2017/10/01/hey-siri.html
To avoid running the main processor all day just to listen for the
trigger phrase, the iPhone’s Always On Processor (AOP) (a small,
low-power auxiliary processor, that is, the embedded Motion
Coprocessor) has access to the microphone signal (on 6S and later). We
use a small proportion of the AOP’s limited processing power to run a
detector with a small version of the acoustic model (DNN).
The acoustic model it is referring to is the trigger phrase "Hey Siri", which it has been highly optimized to detect, again circling back to power and performance considerations.

Power consumption of an iOS application

I want check power usage of my iOS application.
I tried with the Instruments.
In the 'Energy Usage Level' it shows values 1/20 (0 to 20),indicating how much energy your app is using at any given time.
What the value meant 0 to 20?.
And how Can I export the value in to text document
Edit : How can I convert it to percentage of energy usage ?
What Apple mentioned is the following :
The Energy Usage instrument shows a level from 0 to 20, indicating how
much energy your app is using at a given time. These numbers are
subjective. If your app’s energy usage level is occasionally high, it
doesn’t necessarily mean that your app has a problem. Your app may
simply require more energy for some of the tasks it performs. For
example, it may use GPS while performing complex network operations.
This is valid energy use. What you should look for are spikes or areas
of high energy use that are unexpected or that could be performed at
more optimal times.
the numbers are subjective it just can be used as an indicator on how high your usage is, thats all.
the link also provides a way to log the energy usage level.

Foreground app activity over 100%?

I was just monitoring my iOS game's energy usage and I see that the foreground app activity often goes as high as 126%. I am just wondering if this is something I should be concerned about? The energy usage shows a constant value of 1/20--- yet the time column is always "00:00 - 00:00", so I am a little confused about what that means.
Also, is there a way to disable bluetooth, gps in my app since those features are unused? I assume they would contribute to some sort of energy usage. Instruments shows no information other than state is "on" with a time of "00:00".
Based on the Apple docs: https://developer.apple.com/library/content/documentation/Performance/Conceptual/EnergyGuide-iOS/MonitorEnergyWithInstruments.html
The Energy Usage instrument indicates a level from 0 to 20, indicating
how much energy your app is using at any given time. These numbers are
subjective. If your app’s energy usage level is occasionally high, it
doesn’t necessarily mean that your app has a problem. Your app may
simply require more energy for some of the tasks it performs. For
example, it may use the GPS while performing complex network
operations. This is valid energy use. What you should look for are
spikes or areas of high energy use that are unexpected or that could
be performed at more optimal times.
I don't think I'd sweat what you are seeing too much. What is your FPS? Are you maintaining a 60 fps? Your main time is spent on your foreground app, so if you're looking to thin it down you should looking at what your CPU is doing. You an look at Time Profiler if you want to see if you can improve performance there.
That being said, I think users do realize battery life will suffer if you're playing a game. However, that comment should be tempered with the type of game. If you're doing Tic Tac Toe and you're sucking the life out of a battery, I think you'll raise some brows.
You don't have means (which won't get you rejected) to forcibly turn off things. And even if you could you also could end up with angry users too. Say you're using a bluetooth headset ... and you kill bluetooth?
Just make sure your game is fun and people will forgive you ;)

iOS Testing with Instruments - Best Practices

Since I'm developing iOS based applications, I'm also spending much time on getting started with testing applications and debugging performance issues.
After reading the instruments user guide, I'm now able to detect memory leaks, record the current memory size and cpu-usage and much more, which quiet helps a lot!
Now, in order to improve my testing strategy, I'm looking for a kind of bench mark values or standard values for the different instruments (such as cpu- usage, energy consumption, ...). You know what I mean? For example: I have a cpu-usage of 80% over a period of 10 seconds. Is that okay or should I think about performance optimization? Sure, in case of cpu-usage, it depends on the action that the app does over that period of time (e.g. reloading some data or something like that) but is there any rule of thumb or best practices for that?
I already did a research on the internet and only found a video of the iOS tech talk in london from Michael Jurewitz. In that talk, i figured out the following statements that are properly useful for me:
Activity Monitor: Can only be used to compare your app's resource usage to other apps
Allocations: A constantly growing allocations chart is obviously a bad sign for memory leaks. Allocations does not show the real memory size the app uses
VM Tracker: Show overall memory size; Rule of thumb: more than 100 MB dirty size of an app is far too much
...
Now I need some "rules of thumb", especially for the CPU Monitor (where is the boundary between good case and bad case?) and Energy Consumption (Level..?).
Do you have any tips for me or do you know some articles I can read through?
Thanks a lot!
Philipp

windows phone diagnostics logging

is it possible to get memory and CPU usage in windows phone (sdk 7.1) application?
what would be the best way to retrieve that data from the application for further analysis?
Try the Windows Phone Performance Analysis tool, it allows you to profile CPU usage, memory usage and record garbage collection:
If you're looking to analyze performance as well, take a look at the Frame Rate counters (these are enabled by default when you are debugging your app)
You'll want to keep your FPS high, and your screen fill rate low (anything above 3 or so is cause for deep concern, since it means your screen is being redrawn 3x for every frame; not the best thing for performance)
Jeff Wilcox has a good summary on this too which is worth reading.

Resources