Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rmastbro

macrumors member
Original poster
Jun 14, 2009
93
1
I have created a very simple Applescript to help me analyze battery uptime usage for my new 2012 11" i7/8/256 Air running ML.

I wanted to confirm my battery uptime and thought others might be interested in doing the same. The script refreshes any website over and over again automatically. For my test I have set the screen brightness at 50% and keyboard backlight about 20%, no bluetooth, running ML.

1) Make sure you Macbook is fully charged (100%) and you have setup energy saver so that the computer and display never sleep for this test.

2) Turn your keyboard backlight and screen brightness to a desired level

3) Unplug the power connector

4) Copy Applescript (below) to Applescript Editor (you can find this undder Utilities) under and click RUN. I have a youtube video setup to refresh every 60 seconds. Feel free to update this to any youtube or automatic streaming URL and you can change the delay time.

5) Every 60 seconds "Uptime log.txt" (written to the desktop) will be updated with the current date time and the battery level at that time.

6) Let your macbook run until the battery is exhausted

7) Now when the macbook restarts you can view the output file and calculate the time difference from the first entry and the last to get you uptime.

During several tests my fans were running about 2000rpm.

I am averaging about 4:30 - 4:45 hours of uptime constantly streaming a youtube video.

Hope this help anyone wanted to confirm their uptime battery usage.

Here's the Applescript I am using (cut and paste this to your Applescript Editor)
--------------------------------------------------------------------------------------------
repeat

-- Insert any URL as desired
open location "http://www.youtube.com/watch?v=AcLCfUutnnI"

-- Set any delay to a desired value. Every 60 seconds the file Uptime log.txt will be updated
delay 60

set thePath to (path to desktop as Unicode text) & "Uptime log.txt"

set fRef to (open for access file thePath with write permission)
try
set myDate to date string of (current date)
set myTime to time string of (current date)
set myDatetime to myTime & " " & myDate
write myDatetime to fRef starting at eof

set maxCapacity to do shell script "ioreg -w0 -l | grep \"\\\"MaxCapacity\\\" =\""
set maxLevel to the last word of maxCapacity
set curCapacity to do shell script "ioreg -w0 -l | grep \"\\\"CurrentCapacity\\\" = \""
set curLevel to the last word of curCapacity
set battPct to round (100 * curLevel / maxLevel)
set output to " : Battery " & battPct & "%"
write output & return to fRef starting at eof

end try
close access fRef

end repeat
--------------------------------------------------------------------------------------------
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.