functional-php/parallel

Parallel implementation of some higher-order functions.

dev-master 2018-01-27 22:49 UTC

This package is auto-updated.

Last update: 2024-04-21 18:46:27 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Average time to resolve an issue Percentage of issues still open Chat on Gitter

Parallel implementation of the higher-order functions map, filter and fold using the phtreads library. This way the computation is distributed across multiple threads so that the whole computational power of the computer can be used.

See the pthreads library requirement. If you are not sure they will be satisfied, install the polyfill.

Installation

composer require functional-php/parallel

Basic Usage

use FunctionalPHP\Parallel as p;

p\map(4, function($i) { return $i + 2; }, [1, 2, 3, 4]);
// will return [3, 4, 5, 6]

p\filter(4, function($i) { return $i % 2 == 0; }, [1, 2, 3, 4]);
// will return [2, 4]

p\fold(4, function($a, $b) { return $a + $b; }, [1, 2, 3, 4], 0);
// will return 10

Testing

You can run the test suite for the library using:

composer test

A test report will be available in the reports directory.

Contributing

Any contribution welcome :

  • Ideas
  • Pull requests
  • Issues