Skip to content

Commit

Permalink
tests: Update CachingIteratorsBench benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jan 4, 2022
1 parent a121d7c commit 8790e85
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/benchmarks/CachingIteratorsBench.php
Expand Up @@ -23,9 +23,9 @@

/**
* @Groups({"CachingIteratorsBench"})
* @Iterations(10)
* @Warmup(5)
* @Revs(200)
* @Iterations(15)
* @Warmup(10)
* @Revs(100)
*/
class CachingIteratorsBench
{
Expand Down Expand Up @@ -67,10 +67,8 @@ public function provideGenerators(): Generator

private function loop(Traversable $input, int $breakAt): Generator
{
$i = 0;

foreach ($input as $key => $value) {
if ($breakAt / 2 === $i++) {
if (0 === $breakAt--) {
break;
}
}
Expand All @@ -82,10 +80,12 @@ private function loop(Traversable $input, int $breakAt): Generator

private function test(Traversable $input, int $size): void
{
$a = iterator_to_array($this->loop($input, $size));
$b = iterator_to_array($this->loop($input, $size));
$c = iterator_to_array($this->loop($input, $size));
$d = iterator_to_array($this->loop($input, $size));
$breakAt = $size / 2;

$a = iterator_to_array($this->loop($input, $breakAt));
$b = iterator_to_array($this->loop($input, $breakAt));
$c = iterator_to_array($this->loop($input, $breakAt));
$d = iterator_to_array($this->loop($input, $breakAt));

if (count($a) !== $size) {
throw new Exception('$a !== $size => Invalid benchmark.');
Expand Down

0 comments on commit 8790e85

Please sign in to comment.