Parallel Map
A map function that runs on all of your CPU cores, for Node.js.
This is meant to be used with synchronous, CPU intensive function to be mapped on large arrays. parallel-map
will split the load across all available CPUs.
Install
$ npm install --save parallel-map
Usage
parallel-map
is asynchronous and returns a Promise. The use of forked processes necessitates that the called function resides in its own file, which should be a Node module that exports a single function.
main.js:
var parallelMap = ;var path = ; ;
function.js:
module { return x * x;}
Note that there is an overhead to forking multiple processes to have them run in parallel, so there will only be a performance gain when the function to execute requires a lot of CPU time.