Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.