Improve application responsiveness and background processing
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { monitorEventLoopDelay } from 'node:perf_hooks';
|
||||
|
||||
let started = false;
|
||||
export function startPerformanceMonitor() {
|
||||
if (started || process.env.EC_PERF_LOG !== 'true') return;
|
||||
started = true;
|
||||
const delay = monitorEventLoopDelay({ resolution: 20 }); delay.enable();
|
||||
setInterval(() => {
|
||||
console.info('[performance]', { eventLoopP95Ms: Math.round(delay.percentile(95) / 1e6),
|
||||
eventLoopMaxMs: Math.round(delay.max / 1e6), rssMiB: Math.round(process.memoryUsage().rss / 1048576) });
|
||||
delay.reset();
|
||||
}, 60_000).unref();
|
||||
}
|
||||
Reference in New Issue
Block a user