• options {Object}
      • resolution {number} The sampling rate in milliseconds. Must be greater than zero. Default: 10.
    • Returns: {Histogram}

    This property is an extension by Node.js. It is not available in Web browsers.

    Creates a Histogram object that samples and reports the event loop delay over time. The delays will be reported in nanoseconds.

    Using a timer to detect approximate event loop delay works because the execution of timers is tied specifically to the lifecycle of the libuv event loop. That is, a delay in the loop will cause a delay in the execution of the timer, and those delays are specifically what this API is intended to detect.

    1. const { monitorEventLoopDelay } = require('perf_hooks');
    2. const h = monitorEventLoopDelay({ resolution: 20 });
    3. h.enable();
    4. // Do something.
    5. h.disable();
    6. console.log(h.min);
    7. console.log(h.max);
    8. console.log(h.mean);
    9. console.log(h.stddev);
    10. console.log(h.percentiles);
    11. console.log(h.percentile(50));
    12. console.log(h.percentile(99));