perf: diagnoistics improvements

This commit is contained in:
2026-06-12 01:22:01 +02:00
parent 29032b5a36
commit dac5cb42a5
29 changed files with 1168 additions and 28 deletions

View File

@@ -0,0 +1,27 @@
import {
describe,
expect,
it
} from 'vitest';
import {
exceedsHighMemoryThreshold,
formatWorkingSetGb,
HIGH_MEMORY_THRESHOLD_KB
} from './high-memory-alert.rules';
describe('high-memory-alert.rules', () => {
it('uses a 2 GiB working-set threshold', () => {
expect(HIGH_MEMORY_THRESHOLD_KB).toBe(2 * 1024 * 1024);
});
it('detects totals at or above the threshold', () => {
expect(exceedsHighMemoryThreshold(HIGH_MEMORY_THRESHOLD_KB - 1)).toBe(false);
expect(exceedsHighMemoryThreshold(HIGH_MEMORY_THRESHOLD_KB)).toBe(true);
expect(exceedsHighMemoryThreshold(HIGH_MEMORY_THRESHOLD_KB + 1024)).toBe(true);
});
it('formats working set totals in gigabytes', () => {
expect(formatWorkingSetGb(1536 * 1024)).toBe('1.50');
expect(formatWorkingSetGb(HIGH_MEMORY_THRESHOLD_KB)).toBe('2.00');
});
});