BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / phantomjs-prebuilt / lib / phantom / examples / loadspeed.js

loadspeed.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
loadspeed.js 674 B Download Raw
1"use strict";
2var page = require('webpage').create(),
3 system = require('system'),
4 t, address;
5
6if (system.args.length === 1) {
7 console.log('Usage: loadspeed.js <some URL>');
8 phantom.exit(1);
9} else {
10 t = Date.now();
11 address = system.args[1];
12 page.open(address, function (status) {
13 if (status !== 'success') {
14 console.log('FAIL to load the address');
15 } else {
16 t = Date.now() - t;
17 console.log('Page title is ' + page.evaluate(function () {
18 return document.title;
19 }));
20 console.log('Loading time ' + t + ' msec');
21 }
22 phantom.exit();
23 });
24}