Skip to content

Commit 0ce5635

Browse files
committed
Add response times to the groups
1 parent e6e2b05 commit 0ce5635

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

Scripts/teaStorek6TestScript1.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { group, sleep } from 'k6';
22

33
import http from 'k6/http';
44

5+
const groupResponseTimes = {};
6+
57
export const options = {
68
stages: [
79
{ duration: '10s', target: 5 },
@@ -19,32 +21,56 @@ export default function () {
1921
const BASE_URL = `http://${ABHAY_IP}:8080/tools.descartes.teastore.webui`;
2022

2123
group('TeaStore Homepage Browse', () => {
24+
const start = new Date();
2225
http.get(`${BASE_URL}/`);
26+
const end = new Date();
27+
const duration = end - start;
28+
groupResponseTimes['TeaStore Homepage Browse'] = (groupResponseTimes['TeaStore Homepage Browse'] || 0) + duration;
2329
sleep(1);
2430
});
2531

2632
group('TeaStore Login User', () => {
33+
const start = new Date();
2734
http.get(`${BASE_URL}/login`);
28-
sleep(1);
35+
const end = new Date();
36+
const duration = end - start;
37+
groupResponseTimes['TeaStore Login User'] = (groupResponseTimes['TeaStore Login User'] || 0) + duration;
38+
sleep(1);
2939
});
3040

3141
group('Black Tea Category Browse', () => {
42+
const start = new Date();
3243
http.get(`${BASE_URL}/category?category=2&page=1`);
44+
const end = new Date();
45+
const duration = end - start;
46+
groupResponseTimes['Black Tea Category Browse'] = (groupResponseTimes['Black Tea Category Browse'] || 0) + duration;
3347
sleep(1);
3448
});
3549

3650
group('Earl Grey (loose) Tea Product View', () => {
51+
const start = new Date();
3752
http.get(`${BASE_URL}/product?id=7`);
53+
const end = new Date();
54+
const duration = end - start;
55+
groupResponseTimes['Earl Grey (loose) Tea Product View'] = (groupResponseTimes['Earl Grey (loose) Tea Product View'] || 0) + duration;
3856
sleep(1);
3957
});
4058

41-
group('TeaStore ViewCart', () => {
59+
group('TeaStore View Cart', () => {
60+
const start = new Date();
4261
http.get(`${BASE_URL}/cart`);
62+
const end = new Date();
63+
const duration = end - start;
64+
groupResponseTimes['TeaStore View Cart'] = (groupResponseTimes['TeaStore View Cart'] || 0) + duration;
4365
sleep(1);
4466
});
4567

4668
group('TeaStore Checkout', () => {
69+
const start = new Date();
4770
http.get(`${BASE_URL}/order`);
71+
const end = new Date();
72+
const duration = end - start;
73+
groupResponseTimes['TeaStore Checkout'] = (groupResponseTimes['TeaStore Checkout'] || 0) + duration;
4874
sleep(1);
4975
});
5076
}

0 commit comments

Comments
 (0)