Execution time, CPU usage and other questions

Good day everyone,
I am new to k6 and would like to try out the xk6 browser on our application. I have attached below, my script and the results obtained.

However, I have the following questions.

1.) How do I get to print the time it took the browser to move from one action to another(in my case, the time it took between clicking on the login button and clicking on the next page)?

2.) How do I determine the number of frames it loads per second? (FPS)

3.) Is there any means to get the log of my CPU usage during the test?

4.) What accounts for the differences in the result 1 and 2, since I obtained both result from same script, same machine and environment? It is weird how the metrics are different.

I would appreciate if someone could put me through with these questions.

Hi Festus,

I moved your post to a separate topic. Please create new topics to avoid derailing the discussion on unrelated topics. And preferably one question per topic, but I’ll try to answer all of your questions here.

  1. You can measure execution time with Date.now(). See this example. This won’t be very precise, but it will give you a reasonable approximation.

    Another thing you can use are k6 groups. They emit a group_duration metric which you can track to get slightly more accurate results.

  1. If you mean analyzing runtime performance like what Chrome DevTools profiling allows, that’s currently not possible.

    Currently you can gather some performance statistics by using the Performance API on the page. For example:

    page.evaluate(() => {
      const entries = performance.getEntries();

    But this won’t give you any sort of FPS information.

    In upcoming releases we’re planning to add support for page.metrics(), but this also wouldn’t give you a metric like FPS.

    If you want, please create an issue on GitHub explaining your use case and what you would like to measure, and we’ll look into it.

  2. Not currently, no. xk6-browser starts a Chrome process, so do you want to measure the k6 CPU usage or the browser’s, or both?

    I think you can do this outside of k6 with some shell scripting.

  3. It’s difficult to say with certainty without looking into your site and environment specifically. Does this happen on other pages? Can you reproduce it from other machines?

    For me while testing test.k6.io the results are within ~100ms of each test run. There will always be some variation, but I agree that the ~700ms difference in your example is a bit high.

    Can you test with test.k6.io and let us know if you experience the same issue? See this example you can use.

Hope this helps,


Hi @Ivan,
Thanks for providing clarification to my questions. I was able to fix the No. 1 question using performance. now ():
The numbers 2-3 aren’t supported by xk6 browser.
For question number 4, please have a look at the test result I attached after running the test.k6.io. The first result from running the test for the first time seemed to have a significant difference from the second and third results. I don’t know if this is normal or somehow connected to my machine.

Thanks again, as I look forward to your feedback.

I wouldn’t call a 100ms p(90) variation “significant” :slight_smile: Even 500ms might be acceptable given the amount of variables that influence metrics like FCP and FMP.

Since you get similar results as I do for test.k6.io, the ~700ms variation for your site could indicate problems you might want to look into. test.k6.io is a fairly simple nearly-static site, so for more complex sites it’s not unexpected that FCP would be higher and more variable.

I suggest testing your site on https://pagespeed.web.dev/ and addressing any issues it reports. Improving FCP and your site’s performance is out of scope for this forum, but there are plenty of guides online that can help you.

Good luck!

Thanks @imiric for the prompt feedback.