fastparallel
Advanced tools
Comparing version 1.3.1 to 1.4.0
24
bench.js
@@ -80,11 +80,15 @@ var max = 1000000 | ||
async.eachSeries([ | ||
benchFastParallel, | ||
benchFastParallelNoResults, | ||
benchAsyncParallel, | ||
benchSetImmediate, | ||
benchFastParallelEach, | ||
benchFastParallelEachResults, | ||
benchAsyncEach, | ||
benchAsyncMap | ||
], bench) | ||
function runBench (done) { | ||
async.eachSeries([ | ||
benchSetImmediate, | ||
benchAsyncParallel, | ||
benchAsyncEach, | ||
benchAsyncMap, | ||
benchFastParallel, | ||
benchFastParallelNoResults, | ||
benchFastParallelEachResults, | ||
benchFastParallelEach | ||
], bench, done) | ||
} | ||
runBench(runBench) |
{ | ||
"name": "fastparallel", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Zero-overhead asynchronous parallel/each/map function call", | ||
@@ -5,0 +5,0 @@ "main": "parallel.js", |
@@ -7,3 +7,3 @@ var xtend = require('xtend') | ||
function parallel (options) { | ||
function fastparallel (options) { | ||
options = xtend(defaults, options) | ||
@@ -15,3 +15,5 @@ | ||
function instance (that, toCall, arg, done) { | ||
return parallel | ||
function parallel (that, toCall, arg, done) { | ||
var holder = last || new Holder(release) | ||
@@ -47,4 +49,2 @@ var i | ||
} | ||
return instance | ||
} | ||
@@ -78,8 +78,7 @@ | ||
var that = this | ||
var i = 0 | ||
this.release = function (err, result) { | ||
that._count-- | ||
that._err = err | ||
that._results.push(result) | ||
if (that._count === 0) { | ||
that._results[i] = result | ||
if (++i === that._count) { | ||
that._callback.call(that._callThat, that._err, that._results) | ||
@@ -90,2 +89,3 @@ that._callback = nop | ||
that._callThat = null | ||
i = 0 | ||
_release(that) | ||
@@ -98,2 +98,2 @@ } | ||
module.exports = parallel | ||
module.exports = fastparallel |
@@ -8,12 +8,12 @@ # fastparallel [![Build Status](https://travis-ci.org/mcollina/fastparallel.svg?branch=master)](https://travis-ci.org/mcollina/fastparallel) | ||
* `async.parallel`: 5641ms | ||
* `async.each`: 2876ms | ||
* `async.map`: 4749ms | ||
* non-reusable `setImmediate`: 2260ms | ||
* `fastparallel` with results: 2657ms | ||
* `fastparallel` without results: 2283ms | ||
* `fastparallel` each: 2316ms | ||
* `fastparallel` map: 2723ms | ||
* non-reusable `setImmediate`: 2450ms | ||
* `async.parallel`: 6347ms | ||
* `async.each`: 3182ms | ||
* `async.map`: 5026ms | ||
* `fastparallel` with results: 2623ms | ||
* `fastparallel` without results: 2556ms | ||
* `fastparallel` map: 2622ms | ||
* `fastparallel` each: 2594ms | ||
These benchmarks where taken via `bench.js` on iojs 1.5.1, on a MacBook | ||
These benchmarks where taken via `bench.js` on iojs 1.8.1, on a MacBook | ||
Pro Retina 2014. | ||
@@ -20,0 +20,0 @@ |
13318
358