HighTechTalks DotNet Forums  

Measuring my application's power consumption

Dotnet Framework (Compact Framework) microsoft.public.dotnet.framework.compactframework


Discuss Measuring my application's power consumption in the Dotnet Framework (Compact Framework) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Scott Gifford
 
Posts: n/a

Default Measuring my application's power consumption - 10-09-2007 , 03:13 AM






Hello,

I'd like to try out a few different implementations of part of my
application to see which is most power efficient. I need to send data
across the network, and I'd like to experiment with UDP vs. TCP, cost
of setting up and tearing down the Internet connection every time,
etc.

To measure power consumption, I'm getting battery status information
by P/Invoking GetSystemPowerStatusEx2. I'm following this
example:

http://msdn2.microsoft.com/en-us/library/aa457088.aspx

and using this documentation for the fields:

http://msdn2.microsoft.com/en-us/library/ms941842.aspx

Everything seems to be working correctly, except that many of the
fields are always zero. In fact, for the primary battery (not the
backup) I only get BatteryVoltage, BatteryLifePercent, BatteryFlag,
and BatteryChemistry. And BatteryLifePercent seems to go down in 5%
intervals, which doesn't give much precision.

My questions are:

* Is there a better way to measure power consumption of an
application, or to get power status information from within .NET?

* Is it surprising that so many of these values would be zero? I'm
disappointed I can't get BatterymAHourConsumed, as it seemed like
it would measure exactly what I wanted.

* Is the delta in battery voltage a reasonable way to measure power
consumption, and is it linear? For example, if in one run
BatteryVoltage drops from 4000 to 3900, and in another it drops
from 3900 to 3800, is it reasonable to assume that they both
consumed about the same amount of power? Is there some place I
can find documentation on this?

Thanks for any thoughts!

---Scott.

Reply With Quote
  #2  
Old   
patilmmilind@gmail.com
 
Posts: n/a

Default Re: Measuring my application's power consumption - 10-09-2007 , 03:51 AM






Hi,

1) Which device you are using ?

2) What is the return value from GetLastError() ?
//Pinvoke signature
[DllImport("coredll.dll", EntryPoint="GetSystemPowerStatusEx2",
SetLastError=true)]

Length of the data returned in the pSystemPowerStatusEx2 buffer
indicates success. Zero indicates failure

3) See the following example, If your application is interested in the
BatteryFlag, BackupBatteryFlag and/or BatteryChemistry elements, you
may wish to implement enum(s) similar to what author did for
ACLineStatus.

http://blogs.msdn.com/davidklinems/a...10/370591.aspx

Regards,
Milind


Reply With Quote
  #3  
Old   
 
Posts: n/a

Default Re: Measuring my application's power consumption - 10-09-2007 , 08:56 AM



Quote:
My questions are:

* Is there a better way to measure power consumption of an
application, or to get power status information from within .NET?
To measure actual power consumption the *best* way is with a ammeter inine
with the battery so you can determine exactly how much power is being drawn
at any given moment. Obviously this works well in a lab, but isn't so
realistic for a fielded device (unless you're custom designing it).

Quote:
* Is it surprising that so many of these values would be zero? I'm
disappointed I can't get BatterymAHourConsumed, as it seemed like
it would measure exactly what I wanted.
No, it's not surprising. The generic battery driver shell provided by
Microsoft provides fields for a whole lot of things, but it's up to the
device OEM to implement these fields. Some of them require certain battery
controllers or smart batteries (or some other specific hardware) that would
add cost to the device for features few people would use. I've seen devices
that gave nothing but the % available, and it was simply a voltage
measurement (which isn't a good measure of "time" left in a battery).

Quote:
* Is the delta in battery voltage a reasonable way to measure power
consumption, and is it linear?
Probably not and no.

Quote:
For example, if in one run
BatteryVoltage drops from 4000 to 3900, and in another it drops
from 3900 to 3800, is it reasonable to assume that they both
consumed about the same amount of power?
No

Quote:
Is there some place I
can find documentation on this?
There should be reasonable online resources to how batteries work and what
the power curves for the different chemistries are that you *might* be able
to use to derive some rough data. Google should get you there. That said,
power monitoring can be a huge ordeal all by itself, and if the device
doesn't have the proper hardware for really measuring it, the numbers you
get are going to be pure guesses that will change in accuracy from device to
device. The nature of many batteries can lead to different results even
from the same device over time (as lithium rechargeable batteries have
"memory").

I think what I'm trying to say here is that you might get some number, but
don't spend a lot of time trying to refine your algorithms and don't base
critical decisions on the data you get.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com





Reply With Quote
  #4  
Old   
Hilton
 
Posts: n/a

Default Re: Measuring my application's power consumption - 10-09-2007 , 06:21 PM



Full charge your battery, run it in a loop doing its thing and see how long
each can go for. Obviously make sure that you turn the screen off after a
fixed time, but keep the device on.

Keep it simple.


"Scott Gifford" <sgifford (AT) suspectclass (DOT) com> wrote

Quote:
Hello,

I'd like to try out a few different implementations of part of my
application to see which is most power efficient. I need to send data
across the network, and I'd like to experiment with UDP vs. TCP, cost
of setting up and tearing down the Internet connection every time,
etc.

To measure power consumption, I'm getting battery status information
by P/Invoking GetSystemPowerStatusEx2. I'm following this
example:

http://msdn2.microsoft.com/en-us/library/aa457088.aspx

and using this documentation for the fields:

http://msdn2.microsoft.com/en-us/library/ms941842.aspx

Everything seems to be working correctly, except that many of the
fields are always zero. In fact, for the primary battery (not the
backup) I only get BatteryVoltage, BatteryLifePercent, BatteryFlag,
and BatteryChemistry. And BatteryLifePercent seems to go down in 5%
intervals, which doesn't give much precision.

My questions are:

* Is there a better way to measure power consumption of an
application, or to get power status information from within .NET?

* Is it surprising that so many of these values would be zero? I'm
disappointed I can't get BatterymAHourConsumed, as it seemed like
it would measure exactly what I wanted.

* Is the delta in battery voltage a reasonable way to measure power
consumption, and is it linear? For example, if in one run
BatteryVoltage drops from 4000 to 3900, and in another it drops
from 3900 to 3800, is it reasonable to assume that they both
consumed about the same amount of power? Is there some place I
can find documentation on this?

Thanks for any thoughts!

---Scott.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.