MCPcopy
hub / github.com/CapSoftware/Cap / evaluateCycles

Function evaluateCycles

apps/desktop/scripts/desktop-memory-soak-lib.js:262–295  ·  view source on GitHub ↗
(
	baselineKb,
	settledCycleKbs,
	options = DEFAULTS,
)

Source from the content-addressed store, hash-verified

260}
261
262export 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
297export function formatMb(kb) {
298 return `${(kb / 1024).toFixed(1)} MB`;

Callers 2

mainFunction · 0.90

Calls 1

toKbFunction · 0.85

Tested by

no test coverage detected