Created
February 24, 2017 20:18
-
-
Save DanWahlin/59bfe87bb17562ba0ef6974d366f2caa to your computer and use it in GitHub Desktop.
Monitor Node Event Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//********************************************************* | |
// Quick and dirty way to detect event loop blocking | |
//********************************************************* | |
var lastLoop = Date.now(); | |
function monitorEventLoop() { | |
var time = Date.now(); | |
if (time - lastLoop > 1000) console.error('Event loop blocked ' + (time - lastLoop)); | |
lastLoop = time; | |
setTimeout(monitorEventLoop, 200); | |
} | |
if (process.env.NODE_ENV === 'development') { | |
monitorEventLoop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment