function WorkAllocator::placeTestsIntoBins
Same name and namespace in other branches
- 11.x core/tests/Drupal/TestTools/TestRunner/WorkAllocator.php \Drupal\TestTools\TestRunner\WorkAllocator::placeTestsIntoBins()
Distribute tests into bins of roughly equal total weight.
Each test, in sorted order, goes into the bin with the lowest total weight so far. When several bins have the lowest weight, the first one is used.
Parameters
TestClassInfoList $tests: The sorted tests.
Return value
array<int,TestClassInfoList> An associative array of bins and the test class names in each bin.
1 call to WorkAllocator::placeTestsIntoBins()
- WorkAllocator::process in core/
tests/ Drupal/ TestTools/ TestRunner/ WorkAllocator.php - Allocates tests to workers.
File
-
core/
tests/ Drupal/ TestTools/ TestRunner/ WorkAllocator.php, line 172
Class
- WorkAllocator
- Allocates available tests to test workers.
Namespace
Drupal\TestTools\TestRunnerCode
private function placeTestsIntoBins(array $tests) : array {
$bins = array_fill(0, $this->totalBins, []);
$binWeights = array_fill(0, $this->totalBins, 0);
foreach ($tests as $key => $test) {
$bin = array_search(min($binWeights), $binWeights, TRUE);
$bins[$bin][$key] = $test;
$binWeights[$bin] += $test['weight'];
}
return $bins;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.