Skip to content

Commit 3a90c4d

Browse files
Merge pull request #128
Fix warmup logic in benchmark iteration handling
2 parents 224b13c + d1cc738 commit 3a90c4d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Benchmark.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ protected function chunks(array $callbacks, ProgressBar $progressBar): void
339339
*/
340340
protected function run(mixed $name, Closure $callback, ProgressBar $progressBar): void
341341
{
342-
$warmedUp = $this->warmup === 0;
342+
$warmedUp = $this->warmup;
343343

344344
for ($i = 1; $i <= $this->iterations + $this->warmup; $i++) {
345345
$result = $this->callbacks->performBeforeEach($name, $i);
@@ -348,8 +348,10 @@ protected function run(mixed $name, Closure $callback, ProgressBar $progressBar)
348348

349349
$this->callbacks->performAfterEach($name, $i, $time, $memory);
350350

351-
if ($warmedUp) {
351+
if ($warmedUp <= 0) {
352352
$this->push($name, $time, $memory);
353+
} else {
354+
$warmedUp--;
353355
}
354356

355357
$progressBar->advance();

0 commit comments

Comments
 (0)