Hello k6 Community!
I’ve been doing a spike into K6 Browser for my organisation, and got a little confused with the custom metrics. I am looking to model an AB Test, which in the protocol-level API I could model with something like:
import http from 'k6/http';
import { Trend } from 'k6/metrics';
const trend1 = new Trend('control_res_time', true)
const trend2 = new Trend('challenger_res_time', true)
export default function () {
const response = http.get('https://www.google.co.uk');
trend1.add(response.timings.duration);
const response2 = http.get('https://duckduckgo.com', );
trend2.add(response2.timings.duration);
}
But reading the K6 Browser documentation, I don’t believe the LCP, CLS metrics are calculated until the finally { page.close() }
resolves - is that correct?
There’s no metrics present in the Response object that I can see, or the Page one. And the Custom Metrics examples using window.performance.mark()
can’t be used prior to the page.goto()
navigation.
So I’m not sure how I could end up with a similar AB test as the protocol-example above, where I could make 2 requests, and pull out browser-specific page load metrics (like LCP or TTFB) to be viewed separately in the summary.