Skip to content

Instantly share code, notes, and snippets.

@xk
Created December 14, 2010 15:42
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 xk/740593 to your computer and use it in GitHub Desktop.
Save xk/740593 to your computer and use it in GitHub Desktop.
lazyEventLoop.js
setTimeout(function () {
t= Date.now()-t;
STOP= 1;
console.log(["ctr: ",ctr, ", t:", t, "ms -> ", (ctr/t).toFixed(2), "KHz"].join(''));
}, 2e3);
var ctr= 0;
var STOP= 0;
var t= Date.now()+ 2;
while (t > Date.now()) ; //get in sync with clock
(function foo () {
if (STOP) return;
process.nextTick(foo);
ctr++;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment