Created
March 22, 2013 02:49
-
-
Save bjornstar/5218577 to your computer and use it in GitHub Desktop.
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 timeoutLengthInMS = 1; | |
var c = 0; | |
function test() { | |
var d1 = process.hrtime(); | |
setTimeout(function() { | |
var dd = process.hrtime(d1); | |
// convert [sec,ns] to msec | |
dd = dd[0] * 1e3 + dd[1]/1e6; | |
if (dd < timeoutLengthInMS) { | |
throw new Error('expected at least ' + timeoutLengthInMS + ', got ' + dd); | |
} | |
++c; | |
if (c % 1000 === 0) | |
console.log(c); | |
test(); | |
}, timeoutLengthInMS); | |
} | |
test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment