Skip to content

Commit

Permalink
improve memory logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Dec 16, 2024
1 parent 603a1fd commit 9d742c2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/memory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeMemory("Memory Tests", () => {
if (i % Math.floor(iterations / 5) === 0) {
const currentMemory = await getMemoryUsage();
console.log(
`Memory after iteration ${i}: ${fmtBytes(currentMemory)} (delta: ${fmtBytes(currentMemory - initialMemory)})`,
`Memory after iteration ${i}: ${fmtBytes(currentMemory)} (diff: ${fmtBytes(currentMemory - initialMemory)})`,
);
// Allow some variance but fail on large increases
expect(currentMemory - initialMemory).toBeLessThan(errorMarginBytes);
Expand All @@ -65,10 +65,11 @@ describeMemory("Memory Tests", () => {

// Final memory check
const finalMemory = await getMemoryUsage();
console.log(`Initial memory: ${fmtBytes(initialMemory)}`);
console.log(`Final memory: ${fmtBytes(finalMemory)}`);
console.log(`Difference: ${fmtBytes(finalMemory - initialMemory)}`);

console.dir({
initial: fmtBytes(initialMemory),
final: fmtBytes(finalMemory),
diff: fmtBytes(finalMemory - initialMemory),
});
expect(finalMemory - initialMemory).toBeLessThan(errorMarginBytes);
}

Expand Down

0 comments on commit 9d742c2

Please sign in to comment.