2011-09-13 00:17:54 +04:00
|
|
|
page = require('webpage').create()
|
2012-01-14 19:13:26 +04:00
|
|
|
system = require 'system'
|
2011-05-26 13:05:03 +04:00
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
if system.args.length is 1
|
|
|
|
console.log 'Usage: loadspeed.coffee <some URL>'
|
2012-05-16 11:37:26 +04:00
|
|
|
phantom.exit 1
|
2011-04-22 19:39:51 +04:00
|
|
|
else
|
2011-05-26 13:05:03 +04:00
|
|
|
t = Date.now()
|
2012-01-14 19:13:26 +04:00
|
|
|
address = system.args[1]
|
2011-05-26 13:05:03 +04:00
|
|
|
page.open address, (status) ->
|
|
|
|
if status isnt 'success'
|
|
|
|
console.log('FAIL to load the address')
|
2011-04-22 19:39:51 +04:00
|
|
|
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')
|
2011-04-22 19:39:51 +04:00
|
|
|
phantom.exit()
|
2011-05-26 13:05:03 +04:00
|
|
|
|