Forked from andrew-aladev/gist:ca150b8ccbbac539ee5d82d8c1c0c25b
Created
October 13, 2016 11:09
-
-
Save chapko/6583186e1e3ddb3427e562dd383ef064 to your computer and use it in GitHub Desktop.
setImmediate overhead
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
'use strict'; | |
function getOverhead() { | |
var immediate = null; | |
var overhead = [0, 0]; | |
var latestStart; | |
function handler() { | |
var diff = process.hrtime(latestStart); | |
overhead[0] += diff[0]; | |
overhead[1] += diff[1]; | |
immediate = setImmediate(handler); | |
latestStart = process.hrtime(); | |
} | |
latestStart = process.hrtime(); | |
handler(); | |
setTimeout(function () { | |
clearImmediate(immediate); | |
console.log(overhead); | |
}, 10000); | |
} | |
getOverhead(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment