2015-04-10 10:51:00 +03:00
|
|
|
"use strict";
|
2011-09-13 00:17:54 +04:00
|
|
|
var page = require('webpage').create(),
|
2012-01-14 19:13:26 +04:00
|
|
|
system = require('system'),
|
2011-05-26 01:00:22 +04:00
|
|
|
t, address;
|
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
if (system.args.length === 1) {
|
2011-05-26 01:00:22 +04:00
|
|
|
console.log('Usage: loadspeed.js <some URL>');
|
2012-05-16 11:37:26 +04:00
|
|
|
phantom.exit(1);
|
2011-05-26 01:00:22 +04:00
|
|
|
} else {
|
2011-06-07 10:52:39 +04:00
|
|
|
t = Date.now();
|
2012-01-14 19:13:26 +04:00
|
|
|
address = system.args[1];
|
2011-05-26 01:00:22 +04:00
|
|
|
page.open(address, function (status) {
|
|
|
|
if (status !== 'success') {
|
|
|
|
console.log('FAIL to load the address');
|
|
|
|
} else {
|
|
|
|
t = Date.now() - t;
|
|
|
|
console.log('Page title is ' + page.evaluate(function () {
|
|
|
|
return document.title;
|
|
|
|
}));
|
|
|
|
console.log('Loading time ' + t + ' msec');
|
|
|
|
}
|
|
|
|
phantom.exit();
|
|
|
|
});
|
2010-12-27 09:45:16 +03:00
|
|
|
}
|