loadspeed.js 674 B

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