10 Replies
      Latest reply on Jan 9, 2018 2:05 PM by Mike Morton
      3DTOPO Level 1 Level 1 (0 points)

        Is there anyway to view how many watts the device is using?

         

        I find that the Energy Usage to be mostly meaningless. I would just like to see how many watts the device is pulling - the energy use rating based on 1-20 is not very meanigful.

         

        For instance, I just reduced the CPU usuage from 40-50% to 20-25% and the energy consumption basically gets the same rating as it did before. Since nothing else changed (GPS use, brightness etc) - it seems like it must be using much less energy than when it was using about double the amount of CPU.

         

        Adding to the confusion, CPU usage reports differ pretty dramatically from the XCode Energy Impact and the Energy Usuage Instrument. And the Average Energy Impact in XCode is very different from the Energy Usage Instrument. Which one is right?

         

        It seems like the most meaningful metric would be to simply show the watts. 5 watts is twice as good as 10 watts.

        • Re: Device Watt Usage
          KMT Level 9 Level 9 (14,505 points)

          Outside of perhaps monitoring power usage while on a charger, I don't think so.

           

          Might be an interesting feature request for the bug reporter, tho.

           

               >5 watts is twice as good as 10

           

          Might be more along the lines of .5 v 1.0, I think

            • Re: Device Watt Usage
              3DTOPO Level 1 Level 1 (0 points)

              Hmm - I don't think the charger would be completley meaningful since it could be drawing more than its actually using to charge the device.

               

              For an iPad I beleive its more around 10-watts. The 10-watt charger it comes with isn't quite enough to power the device completely - but I digress.

                • Re: Device Watt Usage
                  KMT Level 9 Level 9 (14,505 points)

                  Nothing short of tapping in board level is going to be meaningful. You're limited by your tools, of course

                   

                  Just for fun, see: ttps://www.wired.com/2013/04/does-decreased-brightness-increase-your-phones-battery-life/

                   

                  My opinion is that power usage is so subjective that watts/app would be pointless to the dev - witness the tools now, as you've pointed out. Stranger things have happend, tho, which is why the suggestion to bug a feature request.

              • Re: Device Watt Usage
                Mike Morton Level 1 Level 1 (0 points)

                task_info() can return a number of things which might be of use, with task_power_info_v2.task_energy looking the most applicable, though I don’t know the units.

                 

                #warning Copied subset of working code, so may not compile
                #import <mach/mach.h>
                struct task_power_info_v2 powerInfo;
                mach_msg_type_number_t size = sizeof(powerInfo);
                kern_return_t kerr = task_info(mach_task_self(), TASK_POWER_INFO_V2, (task_info_t)&powerInfo, &size);
                if (kerr == KERN_SUCCESS) {
                    NSLog(@"task_energy: %@", @(powerInfo.task_energy));
                } else {
                    NSLog(@"Error with task_info(…TASK_POWER_INFO_V2…): %@", @(mach_error_string(kerr)));
                }
                

                 

                Also: task_absolutetime_info.total_user, task_power_info_v2.cpu_energy.total_user, task_absolutetime_info.threads_user, task_thread_times_info.user_time might illuminate energy usage if not exactly reflect it.

                 

                I tried running one or more background threads with a nonstop loop burning CPU, and some of the above values seemed to be almost exactly the same as others, so perhaps there aren’t actually that many things to pick from. This might not be true for non-CPU energy usage.

                 

                The idea of measuring with a charger is interesting (thanks, KMT) and I’ll try that, though my Kill-A-Watt displays only to a resolution 0.01wh so we might need something more precise. We’d need to control for lots of things (full battery, fresh reboot, nothing else running) and even then it’d be useful only for comparing two versions of some code, not predicting battery.

                 

                I’ll try to measure whether .task_energy correlates with actual watt-hours at least rate of decrease of battery level. If someone beats me to it, please post…