public
Created

  • Download Gist
battery_test.scpt
AppleScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
# Quick and dirty applescript to determine batter life under very light load. This script just navigates Safari to a
# page every 10 seconds to simulate web browsing.
#
# You'll need to change the file output path (in the log method) for your machine.
#
# The test:
# * a freshly charged and calibrated battery
# * dim brightness to 50%
# * turn off bluetooth
# * set display to never go to sleep
# * turn screensaver off
# * Use http://http://codykrieger.com/gfxCardStatus/ to set graphics card to intel only
# * set itunes to play local music at a low volume through headphones only
 
 
set urls to getSiteList()
 
# open a tab in safari
tell application "Safari"
open "about:blank"
end tell
 
set startTime to current date
log {" -------------- starting", startTime}
 
# repeat until mac goes to sleep
repeat
tell application "Safari"
set n to random number from 1 to (count urls)
set myUrl to "http://" & (item n of urls)
set URL of document 1 to myUrl
delay 10
end tell
# record the time and elapsed seconds
log {"running ... ", startTime}
end repeat
 
on log {msg, startTime}
set now to current date
set elapsed to now - startTime
set msg to (now as string) & " (" & (elapsed as string) & " sec): " & msg
set fileRef to open for access ("/Users/andre/Desktop/battery_test.txt" as string) with write permission
write msg & "
" to fileRef starting at eof
close access fileRef
end log
 
# list of sites -- taken from Alexa top sites
on getSiteList()
return every paragraph of "google.com
facebook.com
youtube.com
yahoo.com
live.com
wikipedia.org
baidu.com
blogger.com
msn.com
twitter.com
yahoo.co.jp
google.co.in
taobao.com
google.de
google.com.hk
wordpress.com
amazon.com
sina.com.cn
google.co.uk
microsoft.com
bing.com
google.fr
ebay.com
myspace.com
linkedin.com
flickr.com
craigslist.org
fc2.com
conduit.com
imdb.com
doubleclick.com
go.com
livejasmin.com
aol.com
apple.com
bp.blogspot.com
cnn.com
ask.com
photobucket.com
mediafire.com
adobe.com
about.com
tudou.com
espn.go.com
paypal.com
sogou.com
google.co.id
imageshack.us
cnet.com
livejournal.com
megaupload.com
hi5.com
nytimes.com
livedoor.com
dailymotion.com
godaddy.com
weather.com
deviantart.com
renren.com
yieldmanager.com
amazon.de
digg.com
twitpic.com
spiegel.de
taringa.net
ezinearticles.com
netflix.com
ehow.com
tumblr.com
clicksor.com
ning.com
google.com.eg
badoo.com
zedo.com
tinypic.com
huffingtonpost.com
answers.com
bankofamerica.com
bit.ly
wikimedia.org
secureserver.net
mozilla.com
download.com
sourceforge.net
angege.com
hulu.com
addthis.com
comcast.net
statcounter.com
typepad.com
digitalpoint.com
wordpress.org
orange.fr
stumbleupon.com
dell.com
reference.com
vimeo.com
chase.com
dailymail.co.uk
metacafe.com
zynga.com
guardian.co.uk
foxnews.com
howstuffworks.com
lifehacker.com
barnesandnoble.com
macrumors.com
github.com
costco.com"
end getSiteList
 
# not used
#on readFileToArray(unixPath)
# set tmp to (do shell script "cat '" & unixPath & "'")
# return every paragraph of tmp
#end readFileToArray

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.