{"id":20827700,"url":"https://github.com/peridot-php/peridot-concurrency","last_synced_at":"2025-08-09T15:14:41.675Z","repository":{"id":25867061,"uuid":"29307033","full_name":"peridot-php/peridot-concurrency","owner":"peridot-php","description":"Concurrent spec runner for Peridot","archived":false,"fork":false,"pushed_at":"2015-02-24T17:07:43.000Z","size":1316,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T21:05:17.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://peridot-php.github.io/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"foobaar/jKitchen","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peridot-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-15T16:43:25.000Z","updated_at":"2020-05-15T20:49:24.000Z","dependencies_parsed_at":"2022-08-24T05:11:12.154Z","dependency_job_id":null,"html_url":"https://github.com/peridot-php/peridot-concurrency","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-concurrency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-concurrency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-concurrency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-concurrency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peridot-php","download_url":"https://codeload.github.com/peridot-php/peridot-concurrency/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954427,"owners_count":21830903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T23:12:47.908Z","updated_at":"2025-05-07T21:05:23.106Z","avatar_url":"https://github.com/peridot-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# peridot-concurrency\n\nLets run our specs a lot faster!\n\n[![Build Status](https://travis-ci.org/peridot-php/peridot-concurrency.png)](https://travis-ci.org/peridot-php/peridot-concurrency) [![HHVM Status](http://hhvm.h4cc.de/badge/peridot-php/peridot-concurrency.svg)](http://hhvm.h4cc.de/package/peridot-php/peridot-concurrency)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/peridot-php/peridot-concurrency/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/peridot-php/peridot-concurrency/?branch=master) [![Coverage Status](https://coveralls.io/repos/peridot-php/peridot-concurrency/badge.svg?branch=master)](https://coveralls.io/r/peridot-php/peridot-concurrency?branch=master)\n\nThis plugin includes a runner and reporter that allows you to run your Peridot tests concurrently! Have a bunch of slow WebDriver tests? How about a bunch of DB tests? Tired of waiting? Why not run them at the same time!?!?\n\n## How does it work?\n\nperidot-concurrency leverages good old fashioned non-blocking IO to run our tests concurrently. This plugin creates `N` worker processes as specified on the command line, and each worker communicates with the main process as test results become available. The function responsible for polling workers is the [stream_select](http://php.net/manual/en/function.stream-select.php) function.\n\n## Usage\n\nYou can install via composer:\n\n```\ncomposer require --dev peridot-php/peridot-concurrency\n```\n\nperidot-concurreny can be added to your test workflow like any Peridot extension - that is via the `peridot.php` file:\n\n```php\nuse Evenement\\EventEmitterInterface;\nuse Peridot\\Concurrency\\ConcurrencyPlugin;\n\nreturn function (EventEmitterInterface $emitter) {\n    $concurrency = new ConcurrencyPlugin($emitter);\n};\n```\n\nAfter registering the plugin, your usage screen should have a couple of new options:\n\n![Peridot concurrency usage](https://raw.github.com/peridot-php/peridot-concurrency/master/usage.png \"Peridot concurrency usage\")\n\n### --concurrent\n\nThis is how you signal Peridot to run your tests concurrently. This will start as many worker processes as specified by the new `-p` option (defaulting to 5). In addition to starting workers, this will override the Peridot reporter to use the `ConcurrentReporter` provided by this plugin. This reporter prevents output from being garbled, and offers useful information like the time it takes each suite file to run.\n\n### --processes (-p)\n\nThis new option can be used to specify the number of worker processes to start. It defaults to 5, and the sweet spot will vary from machine to machine.\n\n## OS Support\n\nDue to limitations of the Windows operating system, it is currently not supported by the peridot-concurreny plugin. This has to do with the `stream_select` function not being able to work with file descriptors returned from `proc_open` on the Windows operating system.\n\n`stream_select` is currently the most efficient \"out-of-the-box\" solution for this type of work, but stay tuned for a \"process per test\" runner that works on Windows, and a [pthreads](http://php.net/manual/en/book.pthreads.php) based runner where the extension is available.\n\n## Performance\n\nThere is some overhead with creating processes, so not every suite will improve from using concurrency. For example, if you have a suite that runs in 68ms, it's hard to improve on that. BUT! The test suites run so far, have noticed significant speed improvements, even on the unit level.\n\nperidot-concurrency runs it's own tests concurrently:\n\n### before\n\n![Peridot concurrency suite run serially](https://raw.github.com/peridot-php/peridot-concurrency/master/dot.png \"Peridot concurrency suite run serially\")\n\n### after\n\n![Peridot concurrency suite run concurrently](https://raw.github.com/peridot-php/peridot-concurrency/master/concurrent.png \"Peridot concurrency suite run concurrently\")\n\nOn the machines tested, Peridot's own test suite was run in 1/4th of the time! You can see peridot-concurrency's [travis build](https://travis-ci.org/peridot-php/peridot-concurrency) to see even faster run times.\n\nThe thing to note here is that these are just unit test suites. The amount of time saved running a bulky integration or functional test suite would be even more significant (examples coming soon).\n\n### Fine tuning\n\nAs mentioned before, the exact number of processes to use will vary from machine to machine. Try experimenting with different process numbers to get the most speed out of peridot-concurrency.\n\n## Test Tokens\n\nEach worker process has its own unique ID, and it is surfaced as an environment variable `PERIDOT_TEST_TOKEN`. This may be useful for creating unique resources based on this token. For instance:\n\n```php\n$id = getenv('PERIDOT_TEST_TOKEN');\n$dbname = \"mydb_$id\";\n//create and seed DB identified by $dbname\n//do database things\n```\n\n## Contributing\n\nConcurrency can be tricky business. If you have any issues or ideas please let us know! Pull requests are always welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperidot-php%2Fperidot-concurrency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperidot-php%2Fperidot-concurrency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperidot-php%2Fperidot-concurrency/lists"}