Skip to content

Commit

Permalink
fix: fix throughput samples imputation in corner case
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
jerome-benoit committed Oct 27, 2024
1 parent 8e310d4 commit 8de3cc7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down

0 comments on commit 8de3cc7

Please sign in to comment.