perf: diagnoistics improvements
This commit is contained in:
27
electron/diagnostics/high-memory-alert.rules.spec.ts
Normal file
27
electron/diagnostics/high-memory-alert.rules.spec.ts
Normal 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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user