Skip to content

Instantly share code, notes, and snippets.

@ppcano
Last active May 9, 2020 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppcano/14d66b7b3ec6993ed63eaed8f2ebecae to your computer and use it in GitHub Desktop.
Save ppcano/14d66b7b3ec6993ed63eaed8f2ebecae to your computer and use it in GitHub Desktop.
import http from "k6/http";
import {group} from "k6";
import { Counter } from "k6/metrics";
//adding these metrics to count each group execution
var group1Counter = new Counter("counter_group1");
var group2Counter = new Counter("counter_group2");
export let options = {
vus: 20,
duration: "10s"
};
export default function() {
const totalIterationID = __VU*10000 + __ITER;
// first group executes 33%
if (totalIterationID % 3 == 0) {
group1Counter.add(1);
group("read particular new", function() {
http.get("http://test.loadimpact.com/");
});
} else {
group2Counter.add(1);
group("navigate sport news", function() {
http.get("https://loadimpact.com/");
});
}
}
@pawansinha0612
Copy link

@ppcano - What is this const totalIterationID = __VU*10000 + __ITER; ?? how does 10000 matters in deciding the TPS calculation. i want to generate diffferent load patterns for 4 groups. Its like 1 st group - 50 TPS, 2nd 60 TPS ,3rd 90 TPS and 4th 10 TPS . how to chieve this what changes i will have to do

@ppcano
Copy link
Author

ppcano commented May 9, 2020

@pawanshinha0612

This solution was discussed at https://community.k6.io/t/how-to-distribute-vus-across-different-scenarios-with-k6/49/2?u=ppcano

You cannot configure multiple scenarios with different load configurations at this moment, but grafana/k6#1007 will support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment