Skip to content

Instantly share code, notes, and snippets.

@xk xk/lazyEventLoop.js
Created Dec 14, 2010

Embed
What would you like to do?
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
You can’t perform that action at this time.