Last active
August 29, 2015 14:05
-
-
Save iizukanao/cf12a8c402310c6418de to your computer and use it in GitHub Desktop.
setTimeout issues on Node v0.10.30
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
var counter = 0; | |
function queueNext() { | |
if (++counter === 100) { | |
return; | |
} | |
console.log(counter); | |
setTimeout(function() { | |
queueNext(); | |
}, 12.34); | |
} | |
queueNext(); |
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
var startTime = process.hrtime(); | |
var sleepMs = 100; // milliseconds | |
setTimeout(function() { | |
var diff = process.hrtime(startTime); | |
var elapsedMs = diff[0] * 1000 + diff[1] / 1000000; | |
console.log('expected=' + sleepMs + 'ms, got=' + elapsedMs + 'ms'); | |
}, sleepMs); |
Author
iizukanao
commented
Aug 13, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment