Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 12, 2021
1 parent f34e3ab commit d73251e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/stats/cold/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const getColdStats = function (
) {
const cold = getCold(array, { mean, filter, length })
const coldLoopsTarget = getColdLoopsTarget(array, {
cold,
precisionTarget,
mean,
filter,
Expand Down Expand Up @@ -60,8 +61,12 @@ const getCold = function (array, { mean, filter, length }) {
// Used to estimate the duration of the benchmark in previews.
const getColdLoopsTarget = function (
array,
{ precisionTarget, mean, filter, length },
{ cold, precisionTarget, mean, filter, length },
) {
if (cold <= precisionTarget) {
return 0
}

const minIndex = getIndexFromLength(COLD_MIN_PERCENTAGE, length)
const incrementalMeanMin = mean * (1 - precisionTarget)
const incrementalMeanMax = mean * (1 + precisionTarget)
Expand All @@ -74,8 +79,7 @@ const getColdLoopsTarget = function (
const hotLength = getLengthFromIndex(COLD_MAX_PERCENTAGE, hotIndex)
const coldLengthTarget = Math.max(hotLength - length, 0)
const filterRatio = array.length / length
const coldLoopsTarget = Math.round(coldLengthTarget * filterRatio)
return coldLoopsTarget
return Math.round(coldLengthTarget * filterRatio)
}

const getIndexFromLength = function (percentage, length) {
Expand Down

0 comments on commit d73251e

Please sign in to comment.