Skip to content

Commit

Permalink
Fix NaNs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Babik committed Nov 25, 2023
1 parent c6f776b commit b5d77de
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ class Context {
let child = this.inner.size
let count = this.deltas.length
let total = this.deltas.reduce((a, b) => (a + b), 0)
let percent = total / grandTotal * 100
let mean = total / count
let percent = grandTotal ? (total / grandTotal * 100) : 0
let mean = count ? (total / count) : 0
let first = count ? this.deltas[0] : 0
let max = Math.max(...this.deltas)
let min = Math.min(...this.deltas)
let squaredDifferences = this.deltas.map(value => Math.pow(value - mean, 2))
let meanSquaredDifferences = squaredDifferences.reduce((a, b) => (a + b), 0) / count
let meanSquaredDifferences = count ? (squaredDifferences.reduce((a, b) => (a + b), 0) / count) : 0
let stddev = Math.sqrt(meanSquaredDifferences)
return {
label: this.label,
Expand Down

0 comments on commit b5d77de

Please sign in to comment.