Variadic async (v2)

Revision 2 of this benchmark created by frambach on


Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/async/0.9.0/async.js"></script>

Setup

async.concatAndApply = function(fn) {
      return function(err, responses) {
        return fn.apply(async, [err].concat(responses));
      }
    }
    
    async.bindAndApply = function(fn) {
      return function(err, responses) {
        return fn.bind(async, err).apply(async, responses);
      }
    }
    
    async.unshiftAndApply = function(fn) {
      return function(err, responses) {
        responses.unshift(err);
        return fn.apply(async, responses);
      }
    }
    
    function makeVariadic(parallelMethod) {
      var _async = {};
      _async.prototype = async;
      _async.parallel = function(tasks, callback) {
        return async.parallel(tasks, parallelMethod);
      };
      return function() {
        return _async;
      };
    };
    
    async.variadicConcatAndApply = makeVariadic(async.concatAndApply);
    async.variadicBindAndApply = makeVariadic(async.bindAndApply);
    async.variadicUnshiftAndApply = makeVariadic(async.unshiftAndApply);
    
    function getThing1(callback) {
      callback(null, 1);
    }
    
    function getThing2(callback) {
      callback(null, 2);
    }
    
    function getThing3(callback) {
      callback(null, 3);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
concat and apply
async.parallel([
  getThing1,
  getThing2,
  getThing3
], async.concatAndApply(function(err, thing1, thing2, thing3) {}));
ready
bind and apply
async.parallel([
  getThing1,
  getThing2,
  getThing3
], async.bindAndApply(function(err, thing1, thing2, thing3) {}));
ready
unshift and apply
async.parallel([
  getThing1,
  getThing2,
  getThing3
], async.unshiftAndApply(function(err, thing1, thing2, thing3) {}));
ready
modify async - concat and apply
async.variadicConcatAndApply().parallel([
  getThing1,
  getThing2,
  getThing3
], function(err, thing1, thing2, thing3) {});
ready
modify async - bind and apply
async.variadicBindAndApply().parallel([
  getThing1,
  getThing2,
  getThing3
], function(err, thing1, thing2, thing3) {});
ready
modify async - unshift and apply
async.variadicUnshiftAndApply().parallel([
  getThing1,
  getThing2,
  getThing3
], function(err, thing1, thing2, thing3) {});
ready

Revisions

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

  • Revision 1: published by frambach on
  • Revision 2: published by frambach on