Skip to content

Commit 640cb2c

Browse files
committed
Add http_res_body_size to k6 script
1 parent 4944dfa commit 640cb2c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

k6/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,20 @@ let group_durations = [...new Set(urls.map(url => url.group))]
5353
return trends;
5454
}, {});
5555

56+
let group_sizes = [...new Set(urls.map(url => url.group))]
57+
.reduce((trends, group) => {
58+
trends[group] = new Trend(`http_res_body_size_${group}`, false);
59+
return trends;
60+
}, {});
61+
5662
export default function() {
5763
const url = urls[exec.scenario.iterationInTest % urls.length]
5864
const res = http.get(url.url);
5965
check(res, {
6066
'is status 200': (r) => r.status === 200,
6167
});
6268
group_durations[url.group].add(res.timings.duration);
69+
70+
const body_size = Math.round(parseInt(res.headers["Content-Length"]) / 10.24) / 100;
71+
group_sizes[url.group].add(body_size);
6372
}

0 commit comments

Comments
 (0)