From 8de3cc7805fb7d9df59151a9e163c99053bd3841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 27 Oct 2024 17:47:34 +0100 Subject: [PATCH] fix: fix throughput samples imputation in corner case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/lib.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.js b/src/lib.js index 7f5fa10..775f035 100644 --- a/src/lib.js +++ b/src/lib.js @@ -295,18 +295,19 @@ const buildMeasurementStats = latencySamples => { // Latency latencySamples.sort((a, b) => a - b) + const latencyStats = getStatsSorted(latencySamples) // Throughput const throughputSamples = latencySamples .map( - sample => (sample !== 0 ? 1e9 / sample : 1e9 / latencyAvg) // Use latency average as imputed sample + sample => (sample !== 0 ? 1e9 / sample : 1e9 / latencyStats.avg) // Use latency average as imputed sample ) .sort((a, b) => a - b) return { samples: latencySamples.length, ss: latencySamples.length >= minimumSamples, - latency: getStatsSorted(latencySamples), + latency: latencyStats, throughput: getStatsSorted(throughputSamples), } }