Skip to content

Instantly share code, notes, and snippets.

@bjornstar
Created March 22, 2013 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjornstar/5218577 to your computer and use it in GitHub Desktop.
Save bjornstar/5218577 to your computer and use it in GitHub Desktop.
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