xk6-browser icon indicating copy to clipboard operation
xk6-browser copied to clipboard

Do not measure and record the metrics for navigating to `about:blank` when we launch a new `page`

Open ankur22 opened this issue 3 years ago • 0 comments

When running a simple test, such as this:

import { chromium } from 'k6/x/browser';

export default function () {
  const browser = chromium.launch();
  const context = browser.newContext();
  const page = context.newPage();

  page.goto("https://test.k6.io/browser.php", {
    waitUntil: "networkidle",
  });
}

A user would expect the output metric results to show the performance of navigating to https://test.k6.io/browser.php, which should result in the avg, min, med, max, p(90) and p(95) values all to match, but what we actually see is:

     browser_dom_content_loaded...: avg=11.5µs   min=11µs     med=11.5µs   max=12µs     p(90)=11.9µs   p(95)=11.95µs 
     browser_loaded...............: avg=79.5µs   min=75µs     med=79.5µs   max=84µs     p(90)=83.1µs   p(95)=83.55µs 
     data_received................: 0 B  0 B/s
     data_sent....................: 39 B 47 B/s
     iteration_duration...........: avg=829.71ms min=829.71ms med=829.71ms max=829.71ms p(90)=829.71ms p(95)=829.71ms
     iterations...................: 1    1.203378/s

iteration_duration (correctly) shows all the same values for the different metric attributes, whereas the browser specific metrics, the attributes aren't the same. The reason for this is because we're currently measuring the navigation to about:blank and then combine that with the navigation to https://test.k6.io/browser.php.

It's probably best to ignore the initial events to navigate to about:blank (which are Onload Event and DOMContentLoaded Event), as these measurements only hinder end-users from seeing what they are most interested in.

ankur22 avatar Sep 05 '22 11:09 ankur22