Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent 79dee2b commit 875a2f2
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/report/normalize/stats/scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,14 @@ const getMeasure = function (
return stat
}

if (mean !== undefined) {
return mean
}

if (meanMin !== undefined) {
return meanMin
}

return median
return [mean, meanMin, median].find(isNotEmpty)
}

const MEAN_KINDS = new Set(['duration'])

// Some measures might be `0`, although unlikely. We do not them since they are
// not a good indicator of minimum precision for scales.
// `undefined` happens when there was not enough measures.
// Measures that are `0`are not a good indicator of minimum precision for scale.
const isNotEmpty = function (measure) {
return measure !== 0 && measure !== undefined
return measure !== undefined && measure !== 0
}

// Possible scales for each unit kind.
Expand Down

0 comments on commit 875a2f2

Please sign in to comment.