diff options
author | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-02 12:58:01 -0400 |
---|---|---|
committer | Graeme Yeates <yeatesgraeme@gmail.com> | 2015-07-02 13:21:28 -0400 |
commit | 3c900be947697d00eb6fdb0f57c205825a652a5a (patch) | |
tree | 901478bc6e7fb5123a0a603013c5806f1e532320 | |
parent | 84eb0fe61c74479839f9494ba96a7ea235d4812e (diff) | |
download | async-3c900be947697d00eb6fdb0f57c205825a652a5a.tar.gz |
Add benchmarks for some and every
-rw-r--r-- | lib/async.js | 2 | ||||
-rw-r--r-- | perf/suites.js | 60 |
2 files changed, 61 insertions, 1 deletions
diff --git a/lib/async.js b/lib/async.js index 68317d4..ed47c57 100644 --- a/lib/async.js +++ b/lib/async.js @@ -465,7 +465,7 @@ iterator(x, function (v) { if (cb && check(v)) { cb(!defaultValue); - cb = false; + cb = iterator = false; } callback(); }); diff --git a/perf/suites.js b/perf/suites.js index b4ea76b..42611db 100644 --- a/perf/suites.js +++ b/perf/suites.js @@ -180,6 +180,66 @@ module.exports = [ } }, { + name: "some - no short circuit- false", + // args lists are passed to the setup function + args: [[500]], + setup: function(count) { + tasks = _.range(count); + }, + fn: function (async, done) { + async.some(tasks, function(i, cb) { + async.setImmediate(function() { + cb(i >= 600); + }); + }, done); + } + }, + { + name: "some - short circuit - true", + // args lists are passed to the setup function + args: [[500]], + setup: function(count) { + tasks = _.range(count); + }, + fn: function (async, done) { + async.some(tasks, function(i, cb) { + async.setImmediate(function() { + cb(i >= 60); + }); + }, done); + } + }, + { + name: "every - no short circuit- true", + // args lists are passed to the setup function + args: [[500]], + setup: function(count) { + tasks = _.range(count); + }, + fn: function (async, done) { + async.every(tasks, function(i, cb) { + async.setImmediate(function() { + cb(i <= 600); + }); + }, done); + } + }, + { + name: "every - short circuit - false", + // args lists are passed to the setup function + args: [[500]], + setup: function(count) { + tasks = _.range(count); + }, + fn: function (async, done) { + async.every(tasks, function(i, cb) { + async.setImmediate(function() { + cb(i <= 60); + }); + }, done); + } + }, + { name: "defer nextTick", fn: function (async, done) { process.nextTick(done); |