Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created November 3, 2014 02:30
Show Gist options
  • Save briancavalier/e080a3ddced89c1ece84 to your computer and use it in GitHub Desktop.
Save briancavalier/e080a3ddced89c1ece84 to your computer and use it in GitHub Desktop.
Improve reduce perf
var when = require('../../../when');
var a = [];
for(var i=0; i<1000000; ++i) {
a[i] = when.resolve(i);
}
var start = Date.now();
when.reduce(a, add, 0).done(function(r) {
//when.reduceRight(a, add, 0).done(function(r) {
console.log('when.reduce', Date.now() - start, r);
});
function add(x,y) {
return x + y;
//return when.resolve(x + y);
}
when.reduce 998 499999500000
when.reduce 2114 499999500000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment