[英]Phantom JS - How to get performance timing?
With PhantomJS, I want to gather perfomance timing on page load time. 使用PhantomJS,我想收集页面加载时间的性能时序。
I test this 2 methods for gathering metrics 我测试了这两种收集指标的方法
Setting own timing 设定自己的时间
var page = require('webpage').create();
var system = require('system');
var loadingTime;
loadingTime = Date.now();
page.open('http://crawlbin.com', function (status) {
loadingTime = Date.now() - loadingTime;
console.log('Loading time ' + loadingTime + ' msec');
phantom.exit();
});
Result : Loading time 499 msec 结果:加载时间499毫秒
Using W3C Navigation Timing 使用W3C导航时间
var page = require('webpage').create();
var system = require('system');
page.open('http://crawlbin.com', function (status) {
console.log(window.performance.timing.loadEventEnd - window.performance.timing.navigationStart);
phantom.exit();
});
Result : 256 结果:256
But I don't get the same result. 但是我没有得到相同的结果。 Navigation Timing is always less than own timing and Navigation Timing has a much lower value.
导航时间总是小于自己的时间,导航时间的值要低得多。
What is the most accurate measurement? 什么是最准确的测量?
Regrettably, there is something wrong with the way window.performance.navigationStart is set in the performance timeline. 遗憾的是,在性能时间表中设置window.performance.navigationStart的方式存在问题。 I don't know enough C++ to have pinpointed the issue, but I have opened a defect.
我对C ++的了解不足,无法找出问题所在,但是我已经打开了一个缺陷。
I know this isn't an answer, but if all you're looking for is the loadEventEnd timing, what you're capturing in your first instance is as close a representation of the client timing you're trying to measure. 我知道这不是答案,但是如果您要查找的只是loadEventEnd计时,那么您在第一个实例中捕获的内容就是您要衡量的客户端计时的近似表示。
For reference, the defect is here - https://github.com/ariya/phantomjs/issues/13093 供参考,缺陷在这里-https://github.com/ariya/phantomjs/issues/13093
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.