K6.iteration_duration metric value

Hello! total time shown in test summary is 18m33.2s
image
But iteration_duration metric shows different.

Please explain how to relate these 2 values. Also, how do I get total test run time (18m33.2s) as a metric. Thanks

Hi there :wave:

I’m confused by your first screenshot. It shows you’re running with 1 max VUs, but the summary shows 10 VUs were running. Can you share your script and the command you used to run it?

k6 doesn’t expose a metric of the total duration of the test run, but you could create a custom metric to track it. Something like this:

import { Trend } from 'k6/metrics';
const total = new Trend('total_runtime');

export function setup() {
  return Date.now();
}

export function teardown(startTime) {
  total.add(Date.now() - startTime);
}

This is not ideal, as teardown() would fail to run if there was an unhandled exception, but hope it helps.

1 Like