Difference between revisions of "ACPI sleep power drain test script"
Line 72: | Line 72: | ||
The script was originally written by Jan-Hendrik Benter and was modified a little for this page. | The script was originally written by Jan-Hendrik Benter and was modified a little for this page. | ||
+ | |||
+ | |||
+ | [[Category:Scripts]] |
Revision as of 11:51, 9 May 2005
The following script will suspend your notebook to ram and output some statistics about the power drain during suspend to /var/log/battery.log. The output will look something like this:
Di Jan 11 14:01:15 CET 2005 before: 41170 mWh after: 41000 mWh diff: -170 mWh seconds: 1671 sec result: -366 mW Congratulations, your model seems NOT to be affected.
Please save this script to a file, i.e. sleep.sh, make it executable (chmod +x sleep.sh
) and execute it as root while your notebook is on battery. To get representative values you should leave the notebook suspended for at least 20 minutes.
#!/bin/sh # sleep.sh test script for measuring power drain during suspend-to-ram with ACPI # remove USB for external mouse before sleeping if lsmod | grep '^usbhid' >/dev/null ; then /sbin/modprobe -r -s usbhid fi if lsmod | grep '^uhci_hcd' >/dev/null ; then /sbin/modprobe -r -s uhci_hcd fi if lsmod | grep '^ehci_hcd' >/dev/null ; then /sbin/modprobe -r -s ehci_hcd fi hwclock --systohc LOG=/var/log/battery.log date >> $LOG DATE_BEFORE=`date +%s` BAT_BEFORE=`grep 'remaining capacity' /proc/acpi/battery/BAT0/state | awk '{print $3}'` echo "before: $BAT_BEFORE mWh" >> $LOG echo 3 > /proc/acpi/sleep DATE_AFTER=`date +%s` BAT_AFTER=`grep 'remaining capacity' /proc/acpi/battery/BAT0/state | awk '{print $3}'` echo "after: $BAT_AFTER mWh" >> $LOG DIFF=`echo "$BAT_AFTER - $BAT_BEFORE" | bc` SECONDS=`echo "$DATE_AFTER - $DATE_BEFORE" | bc` echo "diff: $DIFF mWh" >> $LOG echo "seconds: $SECONDS sec" >> $LOG USAGE=`echo "($DIFF * 60 * 60) / ($SECONDS)" | bc` echo "result: $USAGE mW" >> $LOG if [ $USAGE -gt -1000 ] then echo "Congratulations, your model seems NOT to be affected." >> $LOG else echo "Your model seems to be affected." >> $LOG fi if [ $SECONDS -lt 1200 ] then echo "!!! The notebook was suspended less than 20 minutes." >> $LOG echo "!!! To get representative values please let the notebook sleep" >> $LOG echo "!!! for at least 20 minutes." >> $LOG fi echo "" >> $LOG if !(lsmod | grep '^ehci_hcd') >/dev/null ; then /sbin/modprobe -s ehci_hcd fi if !(lsmod | grep '^uhci_hcd') >/dev/null ; then /sbin/modprobe -s uhci_hcd fi if !(lsmod | grep '^usbhid') >/dev/null ; then /sbin/modprobe -s usbhid fi hwclock --hctosys
The script was originally written by Jan-Hendrik Benter and was modified a little for this page.