Menu
Scroll for more
This is documentation for the next version of Grafana k6 documentation. 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
| Type | Description |
|---|---|
| ResourceTiming | Returns ResourceTiming. |
ResourceTiming
| Property | Type | Description |
|---|---|---|
| statTime | number | Request start time in milliseconds elapsed since January 1, 1970 00:00:00 UTC. |
| domainLookupStart | number | Time 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. |
| domainLookupEnd | number | Time 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. |
| connectStart | number | Time 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. |
| secureConnectionStart | number | Time 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. |
| connectEnd | number | Time 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. |
| requestStart | number | Time 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. |
| responseStart | number | Time 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. |
| responseEnd | number | Time 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
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();
}
}Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.