Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created January 12, 2013 21:21
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 briancavalier/4520542 to your computer and use it in GitHub Desktop.
Save briancavalier/4520542 to your computer and use it in GitHub Desktop.
Testing nextTick impls
var when, Q;
var i, d, start, p;
when = require('when');
Q = require('q');
//d = Q.defer();
d = when.defer();
p = d.promise;//.then(f);//.then(f).then(f);
// d = new RSVP.Promise();
// p = d;
start = Date.now();
for(i = 0; i<10000; i++) {
p = p.then(f);
}
p.then(function(val) {
console.log(Date.now() - start, val);
});
d.resolve(1);
function f(x) {
console.log(x);
return x + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment