( baselineKb, settledCycleKbs, options = DEFAULTS, )
| 260 | } |
| 261 | |
| 262 | export function evaluateCycles( |
| 263 | baselineKb, |
| 264 | settledCycleKbs, |
| 265 | options = DEFAULTS, |
| 266 | ) { |
| 267 | const maxCycleRatchetKb = toKb(options.maxCycleRatchetMb); |
| 268 | const maxTotalGrowthKb = toKb(options.maxTotalGrowthMb); |
| 269 | const failures = []; |
| 270 | |
| 271 | for (let index = 0; index < settledCycleKbs.length; index += 1) { |
| 272 | const current = settledCycleKbs[index]; |
| 273 | const previous = index === 0 ? baselineKb : settledCycleKbs[index - 1]; |
| 274 | const cycleDeltaKb = current - previous; |
| 275 | const totalDeltaKb = current - baselineKb; |
| 276 | |
| 277 | if (cycleDeltaKb > maxCycleRatchetKb) { |
| 278 | failures.push({ |
| 279 | cycle: index + 1, |
| 280 | type: "cycle-ratchet", |
| 281 | valueKb: cycleDeltaKb, |
| 282 | }); |
| 283 | } |
| 284 | |
| 285 | if (totalDeltaKb > maxTotalGrowthKb) { |
| 286 | failures.push({ |
| 287 | cycle: index + 1, |
| 288 | type: "total-growth", |
| 289 | valueKb: totalDeltaKb, |
| 290 | }); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | return failures; |
| 295 | } |
| 296 | |
| 297 | export function formatMb(kb) { |
| 298 | return `${(kb / 1024).toFixed(1)} MB`; |
no test coverage detected