Power consumption script (Was: [ltp] T41p suspend to RAM on
2.6.11.3)
Daniel Stodden
linux-thinkpad@linux-thinkpad.org
Fri, 18 Mar 2005 15:58:13 +0100
On Thu, 2005-03-17 at 15:55 +0100, Martin Samuelsson wrote:
> On Thu, Mar 17, 2005 at 10:13:25AM +0100, Daniel Stodden wrote:
> > i've just written a small script to measure sleep power consumption on
> > each suspend to ram. results below, though i did not take the full 15
> > minutes.
>
> Even if it would be simple enough to myself grep and awk from
> /proc/acpi/battery/BAT0/state I'm lazy enough to ask, could you please
> share the script?
>
> > Mar 17 09:59:42 localhost acpi: enter: 1111049982 s, 40340 mWh
> > Mar 17 10:07:38 localhost acpi: leave: 1111050458 s, 40270 mWh
> > Mar 17 10:07:38 localhost acpi: power consumption: 70 mWh / 476 s = 529
> > mWh/h
sure.
dns@thinkpad:~$ cat /etc/acpi/power.sh
source /etc/acpi/common.sh
function unixtime {
date +%s
}
function capacity {
sed -ne's/remaining capacity: *\([0-9]*\) mWh/\1/p'
< /proc/acpi/battery/BAT0/state
}
function power_enter {
time1=$(unixtime)
power1=$(capacity)
echo "enter: $time1 s, $power1 mWh" | log
}
function power_leave {
time2=$(unixtime)
power2=$(capacity)
echo "leave: $time2 s, $power2 mWh" | log
dtime=$[time2-time1]
[ $dtime -ne 0 ] || exit
dpower=$[power1-power2]
consume=$[dpower*3600/dtime]
echo "power consumption: $dpower mWh / $dtime s = $consume mW" |
log
}
dns@thinkpad:~$ cat /etc/acpi/common.sh
#
# $Id: common.sh,v 1.2 2005/03/16 14:05:50 dns Exp $
#
HIBERNATE=/usr/sbin/hibernate
function suspend_enter {
/bin/run-parts --arg=start /etc/acpi/suspend.d
}
function suspend_leave {
/bin/run-parts --arg=stop --reverse /etc/acpi/suspend.d
}
function log {
/usr/bin/logger -tacpi
}
dns@thinkpad:~$ cat /etc/acpi/sleep.sh
#!/bin/sh
#
# $Id: sleep.sh,v 1.4 2005/01/20 08:20:55 dns Exp $
#
source /etc/acpi/common.sh
source /etc/acpi/power.sh
suspend_enter
power_enter
$HIBERNATE -F /etc/hibernate/sleep.conf
power_leave
suspend_leave
> Wouldn't that simply be 529 mW ? ;)
yessssir. that was corrected a minute after i pushed the send button and
reread what i did there :P
all i can say to defend myself is that i fixed an similarly embarrassing
one this morning on thinkwiki. and that one wasn't from me:
http://www.thinkwiki.org/ACPI_sleep_power_drain_test_script?diff=0&oldid=1841
so i'm in good company around here, right? :D
regards,
daniel