- Home /
How can I check how much battery consumption for my game?
I'm trying to improve the performance for my game. (I find a very useful video here). My target is: reducing the battery consumption as much as possible. So I need a tool to check how much battery consumption for my game (simulator or something), or at least a method to read the stats. I see this forum thread discuss about Optimizing Battery Consumption, but my question is far more fundamental - just how to check how much battery consumption for my game? I see that forum post uses Xcode to monitor battery consumption, but I use Windows - Visual Studio (or MonoDevelop).
Answer by meat5000 · Feb 03, 2018 at 11:33 AM
You lack information here. Android? iPhone? Laptops? What?
Battery consumption is a relative concept, really. No batteries perform the same. Its always a 'Best Guess' scenario. Generally, if you give an indication of the state of usage of the Processors (none to maxed out) then the user can generally decide whether or not to invoke power saving options if they find their battery being drained quickly. Optional is good because most people dont care much about power usage and just want Maximum performance and Quality. That said, having some automatic scaling is a good thing for lower end devices where as the dev you want to not compromise on experience. You can tie this in the the Quality Settings interface.
https://docs.unity3d.com/ScriptReference/SystemInfo-batteryLevel.html https://docs.unity3d.com/ScriptReference/SystemInfo-batteryStatus.html
First determine whether the Device is Plugged in or not, using the batteryStatus info. If it is, run at max performance (provided the device is still actually charging despite being plugged in, unless full). If not plugged in, take timestamps of the battery level at set intervals and you will have a nice simple indication of the actual drain and a good idea of time left.
If when plugged in your timestamps show the device is still draining, the constraints should be applied until the battery level starts increasing.
Such options could be exposed in your games settings menu. Or not.
Some devices come with temperature sensors. In these cases it is probably more preferable to monitor the temperature of the GPU, not only for safety reasons (personal and of device) but because it is a decent indication of the actual strain on the system caused by the Game. It also correlates more or less directly with level of power consumption and hence battery drain.
Sorry for my lacking of information, my platform target is Android. Thanks for your detail explanation, I truly appreciate it. But I still wonder how can I check it the relative amount of energy consumption on my development PC first (before checking on real device). For example: there is an X statistics (that is shown in Unity Editor or something) can reflect energy consumption, if I can deter$$anonymous$$e what X is, then I can modify my code to deduce X thus I can eli$$anonymous$$ate the unnecessary wasting of power. This question is about what is X.
Sounds like you may need to take this outside of Unity. Get a realtime program to check your Temperatures and Power load on your System. The OS can deter$$anonymous$$e these figures but a third party app makes it easier. $$anonymous$$ake notes of what general consumption you get under varying conditions, particularly when the CPU and GPU are both under the most strain, by checking the program. You will need to use this information to draw up an 'Analogue'. Unless you are using a laptop and so can measure consumption directly you can only observe, make notes of figures and draw it up on a graph. Draw a line through the points. There's your analogue. PC power model and Android power model will be quite different but if you deter$$anonymous$$e the characteristic performance you can get a good guess. $$anonymous$$obile processors and PC processors will simply not handle the same. The likely scenario is that $$anonymous$$obile processors generally being less efficient will spend more energy on the same tasks a PC processor can breeze through. $$anonymous$$obile processors have less hardware capability and so some CPU emulation or alternative process is required. As I said, I think it's a best guess scenario and you shouldnt worry about being precise. As a generalism, $$anonymous$$ax FPS is lowest power drain and $$anonymous$$inimum FPS is maximum power drain points, or close enough, as these are the places the system struggles or relaxes the most. Its not a direct translation dut itll work.
Your answer
Follow this Question
Related Questions
URP Post Processing Volume Mobile Bloom 30 FPS LOCK 0 Answers
slow rendering and frozen frames in unity 2019.4.16f 3 Answers
Empty scene @ 60fps vs City Scene @140fps... ????? 0 Answers
Do non-rendered gameobjects use memory? 1 Answer
Unity 5 - enable/disable gameobjects or just renderer/colliders 2 Answers