<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Apapadop</id>
	<title>ThinkWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Apapadop"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/wiki/Special:Contributions/Apapadop"/>
	<updated>2026-05-21T15:13:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.12</generator>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=ACPI_sleep_power_drain_test_script&amp;diff=26510</id>
		<title>ACPI sleep power drain test script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=ACPI_sleep_power_drain_test_script&amp;diff=26510"/>
		<updated>2006-11-23T21:29:38Z</updated>

		<summary type="html">&lt;p&gt;Apapadop: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following script will suspend your notebook to ram and output some statistics about the power drain during suspend to {{path|/var/log/battery.log}}. The output will look something like this:&lt;br /&gt;
&lt;br /&gt;
 Di Jan 11 14:01:15 CET 2005&lt;br /&gt;
 before: 41170 mWh&lt;br /&gt;
 after: 41000 mWh&lt;br /&gt;
 diff: -170 mWh&lt;br /&gt;
 seconds: 1671 sec&lt;br /&gt;
 result: -366 mW&lt;br /&gt;
 Congratulations, your model seems NOT to be affected.&lt;br /&gt;
&lt;br /&gt;
{{NOTE|This Script has some limitations:&lt;br /&gt;
*It is not totally reliable, e.g. on some (all?) R32 the values ACPI reports for the battery are wrong by factor 10. They are actually reported in cWh instead of mWh. The script assumes they are reported in mWh as on most ThinkPads - hence the power consumption appearce to be only a tenth of its actual value.&lt;br /&gt;
*The script assumes you have only one battery. If you have a second battery (for example, an UltraBay Slim battery), take it out for this test or change the BATTERY variable from &amp;quot;BAT0&amp;quot; to &amp;quot;BAT1&amp;quot;. If you do the latter, you will get bogus results if the second battery is run down while sleeping.&lt;br /&gt;
*The usage threshold of 1000 mWh might be a bit a bit too tolerant. You can try lowering it to 500 to be sure.&lt;br /&gt;
*On at least one T23 (2647-GGU) it causes the VGA to stop refreshing after resuming from sleep. This means that you can still blindly type commands to cleanly reboot your machine, but the LCD will statically display whatever was there the moment the script was executed.}}&lt;br /&gt;
&lt;br /&gt;
Please save this script to a file, i.e. {{path|sleep.sh}}, make it executable ({{cmdroot|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.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # sleep.sh test script for measuring power drain during suspend-to-ram with ACPI&lt;br /&gt;
 &lt;br /&gt;
 # default settings, change if needed&lt;br /&gt;
 LOG=/var/log/battery.log&lt;br /&gt;
 BATTERY=BAT0&lt;br /&gt;
 THRESHOLD=1000&lt;br /&gt;
 &lt;br /&gt;
 if ! grep -q '^charging state:.*discharging' /proc/acpi/battery/$BATTERY/state; then&lt;br /&gt;
    echo 'Not running on battery power, did you forget to disconnect the charger?'&lt;br /&gt;
    exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 if [ &amp;quot;$UID&amp;quot; != &amp;quot;0&amp;quot; ]; then&lt;br /&gt;
    echo 'This script can only be run by root.'&lt;br /&gt;
    exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 # remove USB for external mouse before sleeping&lt;br /&gt;
 if lsmod | grep '^usbhid' &amp;gt;/dev/null ; then&lt;br /&gt;
    /sbin/modprobe -r -s usbhid&lt;br /&gt;
 fi&lt;br /&gt;
 if lsmod | grep '^uhci_hcd' &amp;gt;/dev/null ; then&lt;br /&gt;
    /sbin/modprobe -r -s uhci_hcd&lt;br /&gt;
 fi&lt;br /&gt;
 if lsmod | grep '^ehci_hcd' &amp;gt;/dev/null ; then&lt;br /&gt;
    /sbin/modprobe -r -s ehci_hcd&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 # save system time&lt;br /&gt;
 hwclock --systohc&lt;br /&gt;
 &lt;br /&gt;
 # get start values&lt;br /&gt;
 date &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 DATE_BEFORE=`date +%s`&lt;br /&gt;
 BAT_BEFORE=`grep 'remaining capacity' /proc/acpi/battery/$BATTERY/state | awk '{print $3}'`&lt;br /&gt;
 &lt;br /&gt;
 # go to sleep&lt;br /&gt;
 if [ -e /proc/acpi/sleep ]; then&lt;br /&gt;
     echo 3 &amp;gt; /proc/acpi/sleep&lt;br /&gt;
 else&lt;br /&gt;
     echo -n mem &amp;gt; /sys/power/state&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 # get end values&lt;br /&gt;
 DATE_AFTER=`date +%s`&lt;br /&gt;
 BAT_AFTER=`grep 'remaining capacity' /proc/acpi/battery/$BATTERY/state | awk '{print $3}'`&lt;br /&gt;
 &lt;br /&gt;
 # do the calculations &lt;br /&gt;
 DIFF=`echo &amp;quot;$BAT_AFTER - $BAT_BEFORE&amp;quot; | bc`&lt;br /&gt;
 SECONDS=`echo &amp;quot;$DATE_AFTER - $DATE_BEFORE&amp;quot; | bc`&lt;br /&gt;
 USAGE=`echo &amp;quot;($DIFF * 60 * 60) / ($SECONDS)&amp;quot; | bc`&lt;br /&gt;
 &lt;br /&gt;
 # output the results&lt;br /&gt;
 echo &amp;quot;before: $BAT_BEFORE mWh&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 echo &amp;quot;after: $BAT_AFTER mWh&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 echo &amp;quot;diff: $DIFF mWh&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 echo &amp;quot;seconds: $SECONDS sec&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 echo &amp;quot;result: $USAGE mW&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 if [ $USAGE -gt -$THRESHOLD ]&lt;br /&gt;
 then&lt;br /&gt;
     echo &amp;quot;Congratulations, your model seems NOT to be affected.&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 else&lt;br /&gt;
     echo &amp;quot;Your model seems to be affected.&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 fi&lt;br /&gt;
 if [ $SECONDS -lt 1200 ]&lt;br /&gt;
 then&lt;br /&gt;
     echo &amp;quot;!!! The notebook was suspended less than 20 minutes.&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
     echo &amp;quot;!!! To get representative values please let the notebook sleep&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
     echo &amp;quot;!!! for at least 20 minutes.&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 fi&lt;br /&gt;
 echo &amp;quot;&amp;quot; &amp;gt;&amp;gt; $LOG&lt;br /&gt;
 &lt;br /&gt;
 # restore USB support &lt;br /&gt;
 if !(lsmod | grep '^ehci_hcd') &amp;gt;/dev/null ; then&lt;br /&gt;
    /sbin/modprobe -s ehci_hcd&lt;br /&gt;
 fi&lt;br /&gt;
 if !(lsmod | grep '^uhci_hcd') &amp;gt;/dev/null ; then&lt;br /&gt;
    /sbin/modprobe -s uhci_hcd&lt;br /&gt;
 fi&lt;br /&gt;
 if !(lsmod | grep '^usbhid')   &amp;gt;/dev/null ; then&lt;br /&gt;
    /sbin/modprobe -s usbhid&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 # restore system time&lt;br /&gt;
 hwclock --hctosys&lt;br /&gt;
&lt;br /&gt;
The script was originally written by Jan-Hendrik Benter and was modified a little for this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripts]]&lt;/div&gt;</summary>
		<author><name>Apapadop</name></author>
		
	</entry>
</feed>