Menu

This is documentation for the next version of K6. For the latest stable release, go to the latest version.

Open source

timing()

Returns resource timing information for the given request. Most of the timing values become available upon the response, responseEnd becomes available when request finishes.

Returns

TypeDescription
ResourceTimingReturns ResourceTiming.

ResourceTiming

PropertyTypeDescription
statTimenumberRequest start time in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
domainLookupStartnumberTime immediately before the browser starts the domain name lookup for the resource. The value is given in milliseconds relative to startTime, -1 if not available.
domainLookupEndnumberTime immediately after the browser ends the domain name lookup for the resource. The value is given in milliseconds relative to startTime, -1 if not available.
connectStartnumberTime immediately before the user agent starts establishing the connection to the server to retrieve the resource. The value is given in milliseconds relative to startTime, -1 if not available.
secureConnectionStartnumberTime immediately before the browser starts the handshake process to secure the current connection. The value is given in milliseconds relative to startTime, -1 if not available.
connectEndnumberTime immediately after the user agent establishes the connection to the server to retrieve the resource. The value is given in milliseconds relative to startTime, -1 if not available.
requestStartnumberTime immediately before the browser starts requesting the resource from the server, cache, or local resource. The value is given in milliseconds relative to startTime, -1 if not available.
responseStartnumberTime immediately after the browser receives the first byte of the response from the server, cache, or local resource. The value is given in milliseconds relative to startTime, -1 if not available.
responseEndnumberTime immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first. The value is given in milliseconds relative to startTime, -1 if not available.

Example

JavaScript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();

  try {
    const res = await page.goto('https://test.k6.io/');
    const req = res.request();

    const timing = await req.timing();
    console.log(`timing: ${JSON.stringify(timing)}`); // timing: {"startTime":534898988.85297775,...}
  } finally {
    await page.close();
  }
}