Capture response time

How can I capture the response time for a particular action?

Click a login button, and it lands on the home page. I need to capture the response time between clicking the Login button and the home page

Hi @Gerard,

For now, the best way for you to time a click followed by a navigation to another page, is to use You can create a custom metric for this measurement which will be printed out in the summary at the end of the test run.

Here’s a code snippet of how it might look:

import { Trend } from 'k6/metrics';
const clickNavTrend = new Trend('click_nav');
  var start;
  var end;
    start =;
    return Promise.all([
  }).then(() => {
    end =;
    const diff = end - start;

At the end you should see something like:

click_nav........................: avg=395.8    min=374      med=398     max=407      p(90)=404.3    p(95)=405.65

Hope that helps.