axemclion / browser-perf

Performance Metrics for Web Browsers
BSD 2-Clause "Simplified" License
936 stars 61 forks source link

TimelineMetrics always return 0 for Styles and JavaScript #95

Closed tvararu closed 4 years ago

tvararu commented 6 years ago

Hello there! 👋

I'm running this script:

const browserPerf = require('browser-perf');

const action = function (browser) {
  return browser.elementByCssSelector('a[href="/cv/"]')
    .then(el => el.click())
    .then(() => browser.scroll(0, 250));
};

const options = {
  'browsers': [{
    'browserName': 'chrome',
    'debug': false
  }],
  'debug': false,
  'actions': [action],
  'metrics': ['TimelineMetrics']
};

browserPerf('https://vararu.org/', function (err, res) {
  console.log('err', err);
  console.log('res', res);
}, options);

Nothing fancy, really, just navigates to a page and captures some TimelineMetrics. My output is:

$ node browser-perf.js
(node:56985) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
err undefined
res [ { Styles: 0,
    Javascript: 0,
    _browserName: 'chrome',
    _url: 'https://vararu.org/' } ]

I've ran it on other websites (which definitely have layout thrashing, performance issues when switching between pages), but both the JavaScript and Styles aggregates seem to return 0. I looked over TimelineMetrics.prototype.addAggregates_ and the res being passed in is an empty object. Higher up the call stack in TimelineMetrics.prototype.getResults, this.timelineMetrics and this.runtimePerfMetrics.getResults() are both empty objects.

Didn't go further, but am I doing something obvious as to why this wouldn't work?

Setup details: