k6

Finding number of iterations for a given duration

is there is any way to find number of executed iterations for given duration?

i would like to to set certain amount of iterations per minute…
ex: - 10 iterations: at the 1st min

  • 30 iterations at the 2rd min
  • 20 iterations at the 3th min
    we have tried below and its taking duration only and we are not able to limit iterations within a specified duration
    export let options = {
    stages: [
    { duration: “60s”, iterations: 10},
    { duration: “60s”, iterations: 30 }
    ]
    };

Hi @ravi_k6, this will be possible with the new schedulers and the arrival rate base execution.

You are welcome to test the PR, but it is currently under review(by me) and as it is very big and there are still things to be done I would say that at best at least 2 weeks will past before we merge it in master.

We do intend on releasing a version with (primarily) just it, as it is a huge change and our current goal is to do this by the end of June.

@ravi_k6, unfortunately you can’t do this with the current k6 version - stages does not support iterations. As @mstoykov has said, once https://github.com/loadimpact/k6/pull/1007 is merged and released though, you’d be able to run a k6 script like this:

import { check, sleep } from "k6";

export let options = {
    execution: {
        first_stage: {
            type: "shared-iterations",
            vus: 1, // or however many you need
            iterations: 10,
            maxDuration: "60s",
            gracefulStop: "0s",
        },
        second_stage: {
            startTime: "60s",
            type: "shared-iterations",
            vus: 1, // or however many you need
            iterations: 20,
            maxDuration: "60s",
            gracefulStop: "0s",
        },
        third_stage: {
            startTime: "120s",
            type: "shared-iterations",
            vus: 1, // or however many you need
            iterations: 30,
            maxDuration: "60s",
            gracefulStop: "0s",
        },
        // ...
    },
};

export default function () {
    // Do some actual work...
    sleep(Math.random() * 5);
}