| 1 | "use strict"; |
| 2 | var page = require('webpage').create(), |
| 3 | system = require('system'), |
| 4 | t, address; |
| 5 | |
| 6 | if (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 | } |