Performance
monitorEventLoopDelay()
Creates a histogram sampling delays in the event loop. Enable it before observation and disable it afterward. Delay statistics use nanoseconds; resolution uses milliseconds. A short lab is not a production percentile estimate. Tested on Node.js 22.16.0. Example output (one line per entry): ["true true"].
Formal Syntax & Structure
nodejs syntaxnodejs
monitorEventLoopDelay([options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| options | object | Sampling resolution in milliseconds. |
Return Value
IntervalHistogram
Histogram with enable and disable.
Working Example
Example Snippetnodejs
import { monitorEventLoopDelay } from 'node:perf_hooks';import { setTimeout as wait } from 'node:timers/promises';const h = monitorEventLoopDelay({ resolution: 10 });h.enable();try { for (let i = 0; i < 20 && h.count === 0; i++) await wait(15); console.log(h.count > 0, Number.isFinite(h.percentile(50)));}finally { h.disable();}