Created
November 3, 2014 02:30
-
-
Save briancavalier/e080a3ddced89c1ece84 to your computer and use it in GitHub Desktop.
Improve reduce perf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when.reduce 998 499999500000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when.reduce 2114 499999500000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment