bluebird promises vs recursion chaining

Benchmark created by benjamingr on


Preparation HTML

<script>
function chainPromises(){
    var i = Promise.resolve();
    for(var j = 0; j < 1000; j++)
        i = i.then(function(){ return Promise.resolve(j); });
    return i;
}
function recurse(){
   var i = Promise.resolve(1000);
   return i.then(function rec (j){
       if(j > 0) return Promise.resolve(j-1).then(rec);
   });
}

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
recurse
// async test
recurse().then(function(){ deferred.resolve(); })
ready
chainPromises
// async test
chainPromises().then(function(){ deferred.resolve(); })
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by benjamingr on