Skip to content

Instantly share code, notes, and snippets.

@cvan
Last active February 27, 2020 22:56
Show Gist options
  • Save cvan/d5127262cb6873aa93eecdae3bdee9e3 to your computer and use it in GitHub Desktop.
Save cvan/d5127262cb6873aa93eecdae3bdee9e3 to your computer and use it in GitHub Desktop.
monitor Node.js event-loop delays (requires Node.js v11+)
// Source: https://twitter.com/jasnell/status/1233135311959445504
//
// PSA: Did you know that since Node.js 11.0.0 there's been a built-in mechanism for monitoring event loop delay?
const { monitorEventLoopDelay } = require('perf_hooks');
const h = monitorEventLoopDelay({ resolution: 20 });
h.enable();
// Do something.
h.disable();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment