Last active
August 4, 2017 14:32
-
-
Save Lax/4e4e8f16d5c24ec7756d18b0a46bc781 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(), | |
system = require('system'), | |
t, address; | |
if (system.args.length === 1) { | |
console.log('Usage: loadspeed.js <some URL>'); | |
phantom.exit(); | |
} | |
t = Date.now(); | |
address = system.args[1]; | |
page.open(address, function(status) { | |
if (status !== 'success') { | |
console.log('FAIL to load the address'); | |
} else { | |
t = Date.now() - t; | |
console.log('Loading ' + system.args[1]); | |
console.log('Loading time ' + t + ' msec'); | |
var title = page.evaluate(function() { | |
return document.title; | |
}); | |
console.log('Page title is ' + title); | |
} | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment