Kaynağa Gözat

Add http_res_body_size to k6 script

DarthSim 2 yıl önce
ebeveyn
işleme
640cb2c461
1 değiştirilmiş dosya ile 9 ekleme ve 0 silme
  1. 9 0
      k6/index.js

+ 9 - 0
k6/index.js

@@ -53,6 +53,12 @@ let group_durations = [...new Set(urls.map(url => url.group))]
     return trends;
     return trends;
   }, {});
   }, {});
 
 
+let group_sizes = [...new Set(urls.map(url => url.group))]
+  .reduce((trends, group) => {
+    trends[group] = new Trend(`http_res_body_size_${group}`, false);
+    return trends;
+  }, {});
+
 export default function() {
 export default function() {
   const url = urls[exec.scenario.iterationInTest % urls.length]
   const url = urls[exec.scenario.iterationInTest % urls.length]
   const res = http.get(url.url);
   const res = http.get(url.url);
@@ -60,4 +66,7 @@ export default function() {
     'is status 200': (r) => r.status === 200,
     'is status 200': (r) => r.status === 200,
   });
   });
   group_durations[url.group].add(res.timings.duration);
   group_durations[url.group].add(res.timings.duration);
+
+  const body_size = Math.round(parseInt(res.headers["Content-Length"]) / 10.24) / 100;
+  group_sizes[url.group].add(body_size);
 }
 }