I fidgeted for new nodejs and phantomjs objects and wrote some code to measure page load time. I found that page load time is different between phantomjs code wrapped in nodejs compared to pure phantomjs code. Below is the code: phantomjs and nodejs for comparison:
Nodejs:
var http = require('http'), phantom = require('phantom'); url = require("url"); http.createServer(function (request, response) { var start = Date.now(); request.on('end', function () { phantom.create(function(ph) { ph.createPage(function(page) { var _get = url.parse(request.url, true).query; page.open(_get[url], function(status) { if (status == 'success') { var time = Date.now() - start; console.log(time); } }); }); }); }); }).listen(80,'');
Phantomjs:
var page = require('webpage').create(); var system = require('system'); var address = system.args[1]; var time = 0; var start = Date.now(); page.open(address, function (status) { time = Date.now() - start; console.log(time + ''); });
The time is usually 4 times longer when testing a site using phantomjs. Any ideas?
source share