UNPKG

552 BJavaScriptView Raw
1// phantomjs test script
2// opens url and reports time to load
3// requires an active internet connection
4var page = require('webpage').create()
5var system = require('system')
6var t
7var address
8
9if (system.args.length === 1) {
10 console.log('Usage: loadspeed.js <some URL>')
11 phantom.exit()
12}
13
14t = Date.now()
15address = system.args[1]
16page.open(address, function (status) {
17 if (status !== 'success') {
18 console.log('FAIL to load the address')
19 } else {
20 t = Date.now() - t
21 console.log('Loading time ' + t + ' msec')
22 }
23
24 phantom.exit()
25})
\No newline at end of file