Here is my very simple K6 script that I am running:
import {group } from "k6";
import { Trend} from "k6/metrics";
let response = null;
let loginTime = new Trend('login_time');
import http from "k6/http";
export let options = {
stages: [
{iterations: 1}
]
};
export default function(){
group("Log In", function(){
let url = "myurl";
let headers = {
headers: {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"connection": "keep-alive"
}
};
response = http.get(url,headers);
loginTime.add(response.timings.duration);
console.log("The duration for this request was:" + response.timings.duration);
})
};
The script just sends one request and runs for one interation and I save the duration of this request to a Trend called 'login_time'.
The stats that K6 prints at the end are as follows:
data_received..............: 29 kB 9.0 kB/s
data_sent..................: 3.4 kB 1.1 kB/s
group_duration.............: avg=3.15s min=3.15s med=3.15s max=3.15s p(90)=3.15s p(95)=3.15s
http_req_blocked...........: avg=414.88ms min=2µs med=291.79ms max=1.31s p(90)=976.28ms p(95)=1.14s
http_req_connecting........: avg=17.55ms min=0s med=25.97ms max=31.96ms p(90)=31.1ms p(95)=31.53ms
http_req_duration..........: avg=216.66ms min=29.72ms med=231.06ms max=478.72ms p(90)=407.62ms p(95)=443.17ms
http_req_receiving.........: avg=407.68µs min=119.9µs med=205.8µs max=1.33ms p(90)=892.84µs p(95)=1.11ms
http_req_sending...........: avg=74.86µs min=12.4µs med=76.8µs max=170.2µs p(90)=142.79µs p(95)=156.49µs
http_req_tls_handshaking...: avg=102.44ms min=0s med=73.61ms max=315.35ms p(90)=238.5ms p(95)=276.93ms
http_req_waiting...........: avg=216.18ms min=29.59ms med=230.68ms max=477.3ms p(90)=406.68ms p(95)=441.99ms
http_reqs..................: 5 1.563597/s
iteration_duration.........: avg=3.15s min=3.15s med=3.15s max=3.15s p(90)=3.15s p(95)=3.15s
iterations.................: 1 0.312719/s
login_time.................: avg=478.721924 min=478.721924 med=478.721924 max=478.721924 p(90)=478.721924 p(95)=478.721924
vus........................: 1 min=1 max=1
vus_max....................: 1 min=1 max=1
As you can see all the stats for my custom Trend 'login_time' show the same number 478.721924.
'login_time' is recording the 'response.timings.duration' - duration here is supposed to be 'http_req_duration'.
So I would expect the stats on the 'http_req_duration' row to be exactly the same as the 'login_time' stats i.e. all show 478.721924.
Instead the stats on the 'http_req_duration' row are completely different and all show different numbers even though only 1 iteration was ran so they should all be the same. (Only the 'max' values shows 478.72).
As only 1 iteration was ran - the data in each column for each row should be the same.
So my question is, can I trust any of these numbers and if so which ones?
Also, I want to report how long login took - is this just the http_req_duration value or do I have to include other values like http_req_blocked....or is that just waiting for K6 getting ready to send the request?