问题
I want to measure the energy consumption of
- my own application (which I can modify)
- 3rd party applications (which I can't modify)
on
- Windows CE 5.0
- Windows Mobile 5/6
Is there some kind of API for this?
If not, can I measure other values which I can use to estimate the energy consumption?
I don't need an exact value like 20 mAh
(although that would be nice) A relative value would suffice, like: "Starting from 100% to 0% charge status, around 20% of the fully charged battery was used by this application"
On the other hand it is very important that the measurement is specific to a single application, i.e. I don't want aggregated measurements for a group of applications, like, "those three applications together consume ..."
回答1:
There's an API for getting information on power consumption but the accuracy of the information returned by this API is OEM dependent (some OEMs don't make the information available at all). More information with example code on this API can be found at http://www.codeproject.com/kb/mobile/Wimopower1.aspx (screenshot of example programs below). As you can see from the screenshot you can tell the battery's voltage, current pull, the type of battery, and more. An accurate measure of instantanious power consumption requires external hardware (and I am assuming you don't want to make a hardware investment to make your measurements).
Take whatever measurements that you get to be relative as they may not be representative of what you would observe when running your program on a different device.
Screenshot of Example Program http://www.codeproject.com/kb/mobile/WiMoPower1/TitleImage.png
回答2:
That seems like a rather difficult thing to measure, because you can't really isolate a single process to run by itself. In fact, if you tried to do so you'd run into difficulty defining what constitutes a "single process" - is it just the userspace code that belongs to that program? Or do you include the kernel code executed on behalf of the program as well? What if the OS optimizes kernel code so that similar requests from different programs are handled together, using a nearly constant amount of energy? Then you couldn't even separate out the energy usage by program.
In a case like this, my inclination would be to measure the expectation value, essentially the average amount of energy used by the application. Ideally you'd start with a large number of systems, all identical except that half of them have the application running and half of them don't. Let each of the systems run under whatever operating conditions you want to test under (same conditions for all devices, of course, except for the fact that half of them are running the app and half are not), and either measure the rate of energy consumption using the standard API, or let the batteries run out and measure how long it takes each unit to drain its battery. Then compare the average result from the devices that were running the app vs. the average result from those that weren't, and you can figure out how much the program increases the power consumption of the computer.
回答3:
If you really want to call the api's yourself I wouldn't know which one to call, but if you just want to know how the power consumption is while running certain applications you could use the acbPowerMeter application.
acbPowerMeter charts the real-time power usage of your device. This utility is very light-weight, allowing benchmarking of your battery usage.
回答4:
Adding my two cents, there are several libraries that can measure energy consumption using the INTEL RALP architecture:
There is PAPI and jRALP.
The use of jRALP seems easy:
double beginning = EnergyCheck.statCheck();
doWork();
double end = EnergyCheck.statCheck();
Unfortunately for the OP, they seem (I'm not sure) not Windows-ready and they work only for certain Intel processors.
来源:https://stackoverflow.com/questions/724349/how-can-i-measure-the-energy-consumption-of-my-application-on-windows-mobile-and