phantomjs/examples/loadspeed.coffee

18 lines
450 B
CoffeeScript
Raw Normal View History

2011-05-26 13:05:03 +04:00
page = new WebPage()
if phantom.args.length is 0
console.log 'Usage: loadspeed.js <some URL>'
phantom.exit()
else
2011-05-26 13:05:03 +04:00
t = Date.now()
address = phantom.args[0]
page.open address, (status) ->
if status isnt 'success'
console.log('FAIL to load the address')
else
2011-05-26 13:05:03 +04:00
t = Date.now() - t
console.log('Page title is ' + page.evaluate( (-> document.title) ))
console.log('Loading time ' + t + ' msec')
phantom.exit()
2011-05-26 13:05:03 +04:00