Skip to content

Commit

Permalink
fix: handle divide by zero in throughput samples
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 10, 2024
1 parent 4b041d2 commit 7d6d9fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ const buildMeasurementStats = latencySamples => {
const latencyRmoe = (latencyMoe / checkDividend(latencyAvg)) * 100

// Throughput
const throughputSamples = latencySamples.map(sample => 1e9 / sample)
const throughputSamples = latencySamples.map(
sample => (sample !== 0 ? 1e9 / sample : 1e9 / latencyAvg) // Use latency average as imputed sample
)
throughputSamples.sort((a, b) => a - b)
const throughputAvg = average(throughputSamples)
const throughputVr = variance(throughputSamples, throughputAvg)
Expand Down

0 comments on commit 7d6d9fe

Please sign in to comment.