-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter.js
32 lines (27 loc) · 892 Bytes
/
counter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import http from 'k6/http';
import { Counter } from 'k6/metrics';
export const options = {
vus: 10,
duration: '20s'
}
const categoriesCounter = new Counter("called_categories");
const usersCounter = new Counter("called_users");
const productsCounter = new Counter("called_products");
export default function () {
switch (Math.floor(Math.random() * 3)) {
case 0:
let categoriesResponse = http.get("https://api.escuelajs.co/api/v1/products");
categoriesCounter.add(1);
break;
case 1:
let usersResponse = http.get("https://api.escuelajs.co/api/v1/products");
usersCounter.add(1);
break;
case 2:
let productsResponse = http.get("https://api.escuelajs.co/api/v1/products");
productsCounter.add(1);
break;
default:
break;
}
}