Created
August 31, 2018 19:21
-
-
Save hlolli/d6be198862f828d41ce5664b8e24d4ee to your computer and use it in GitHub Desktop.
detect thread block in nodejs
This file contains 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
(defn detectBlock [] | |
(let [interval 500 | |
blockDelta 5] | |
(js/setInterval | |
(fn [] | |
(let [last (.hrtime js/process)] | |
(js/setImmediate | |
(fn [] | |
(let [delta (* 1e-6 (aget (.hrtime js/process last) 1))] | |
(when (< blockDelta delta) | |
(js/console.log "node.eventloop_blocked" delta))))))) | |
interval))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment