New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fastparallel

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastparallel - npm Package Compare versions

Comparing version 1.5.3 to 1.6.0

46

bench.js
var max = 1000000
var parallel = require('./')()
var parallelNoResults = require('./')({ results: false })
var bench = require('fastbench')
var async = require('async')

@@ -8,21 +9,2 @@ var parallelize = require('parallelize')

function bench (func, done) {
var key = max + '*' + func.name
var count = -1
console.time(key)
end()
function end () {
if (++count < max) {
func(end)
} else {
console.timeEnd(key)
if (done) {
done()
}
}
}
}
function benchFastParallel (done) {

@@ -90,16 +72,14 @@ parallel(obj, [somethingP, somethingP, somethingP], 42, done)

function runBench (done) {
async.eachSeries([
benchSetImmediate,
benchAsyncParallel,
benchAsyncEach,
benchAsyncMap,
benchParallelize,
benchFastParallel,
benchFastParallelNoResults,
benchFastParallelEachResults,
benchFastParallelEach
], bench, done)
}
var run = bench([
benchSetImmediate,
benchAsyncParallel,
benchAsyncEach,
benchAsyncMap,
benchParallelize,
benchFastParallel,
benchFastParallelNoResults,
benchFastParallelEachResults,
benchFastParallelEach
], max)
runBench(runBench)
run(run)
{
"name": "fastparallel",
"version": "1.5.3",
"version": "1.6.0",
"description": "Zero-overhead asynchronous parallel/each/map function call",

@@ -31,2 +31,3 @@ "main": "parallel.js",

"async": "^0.9.0",
"fastbench": "^1.0.0",
"faucet": "0.0.1",

@@ -33,0 +34,0 @@ "parallelize": "^2.2.0",

@@ -35,2 +35,3 @@ var xtend = require('xtend')

var holder = next()
done = done || nop
if (toCall.length === 0) {

@@ -37,0 +38,0 @@ done.call(that)

@@ -12,3 +12,3 @@ # fastparallel [![Build Status](https://travis-ci.org/mcollina/fastparallel.svg?branch=master)](https://travis-ci.org/mcollina/fastparallel)

* `async.map`: 4981ms
* `parallelize`: 4846ms
* `parallelize`: 3125ms
* `fastparallel` with results: 2391ms

@@ -103,4 +103,14 @@ * `fastparallel` without results: 2350ms

## Why it is so fast?
1. This library is caching funcitons a lot.
2. V8 optimizations: thanks to caching, the functions can be optimized by V8 (if they are optimizable, and I took great care of making them so).
3. Don't use arrays if you just need a queue. A linked list implemented via processes is much faster if you don't need to access elements in between.
4. Accept passing a this for the functions. Thanks to this hack, you can extract your functions, and place them in a outer level where they are not created at every execution.
## License
ISC

@@ -243,1 +243,20 @@ var test = require('tape')

})
test('does not require a done callback', function (t) {
t.plan(4)
var instance = parallel()
var count = 0
var obj = {}
instance(obj, [something, something], 42)
function something (arg, cb) {
t.equal(obj, this)
t.equal(arg, 42)
setImmediate(function () {
count++
cb()
})
}
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc