Device Watt Usage

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. 😉

Replies

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 😉

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…

Just tried .task_energy on an iPhone 5s running iOS 11 and got zero back. Worked nicely on an iPhone 7 Plus running iOS 10. Anyone else got iOS 11 devices they can try it on? Hoping it hasn’t gone away.

Same iPhone 7 Plus now running iOS 11 shows non-zero .task_energy values, so it seems to vary by device model, not OS version.