All files / utilities runtime.ts

100% Statements 4/4
100% Branches 4/4
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 152x               48x 1x     47x    
const BYTES_PER_MEGABYTE = 1024 * 1024;
 
/**
 * Returns the heap currently used by the extension host process in megabytes,
 * or `undefined` where the Node.js process API is not available, as in the
 * browser extension host.
 */
export function getHeapUsedMb(): number | undefined {
	if (typeof process === 'undefined' || typeof process.memoryUsage !== 'function') {
		return undefined;
	}
 
	return Math.round(process.memoryUsage().heapUsed / BYTES_PER_MEGABYTE);
}