Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"dragon-code/codestyler": true,
"ergebnis/composer-normalize": true,
"friendsofphp/php-cs-fixer": true,
"laravel/pint": true,
"pestphp/pest-plugin": true,
"symfony/thanks": true
},
Expand Down
4 changes: 2 additions & 2 deletions src/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function compare(array|Closure ...$callbacks): static
}

/**
* @return \DragonCode\Benchmark\Data\ResultData[]
* @return Data\ResultData[]
*/
public function toData(): array
{
Expand Down Expand Up @@ -156,7 +156,7 @@ protected function chunks(array $callbacks, ProgressBarView $progressBar): void

protected function run(mixed $name, Closure $callback, ProgressBarView $progressBar): void
{
for ($i = 1; $i <= $this->iterations; ++$i) {
for ($i = 1; $i <= $this->iterations; $i++) {
$result = $this->callbacks->performBeforeEach($name, $i);

[$time, $memory] = $this->call($callback, [$i, $result]);
Expand Down
8 changes: 4 additions & 4 deletions src/Services/CallbacksService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ class CallbacksService

public ?Closure $afterEach = null;

public function performBefore(string|int $name): mixed
public function performBefore(int|string $name): mixed
{
return $this->perform($this->before, $name);
}

public function performBeforeEach(string|int $name, int $iteration): mixed
public function performBeforeEach(int|string $name, int $iteration): mixed
{
return $this->perform($this->beforeEach, $name, $iteration);
}

public function performAfter(string|int $name): mixed
public function performAfter(int|string $name): mixed
{
return $this->perform($this->after, $name);
}

public function performAfterEach(string|int $name, int $iteration, float $time, float $memory): mixed
public function performAfterEach(int|string $name, int $iteration, float $time, float $memory): mixed
{
return $this->perform($this->afterEach, $name, $iteration, $time, $memory);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/CollectorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CollectorService
{
protected array $data = [];

public function push(string|int $name, array $values): static
public function push(int|string $name, array $values): static
{
$this->data[$name][] = $values;

Expand Down
4 changes: 2 additions & 2 deletions src/Services/ResultService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
) {}

/**
* @return \DragonCode\Benchmark\Data\ResultData[]
* @return ResultData[]
*/
public function get(array $collections): array
{
Expand Down Expand Up @@ -83,7 +83,7 @@ protected function max(array $times, array $memory): MetricData
protected function avg(array $times, array $memory): MetricData
{
return $this->metric(
time : array_sum($times) / count($times),
time : array_sum($times) / count($times),
memory: array_sum($memory) / count($memory),
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Services/RunnerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ protected function clean(): void
protected function run(Closure $callback, array $parameters = []): array
{
$memoryFrom = $this->memory->now();
$startAt = hrtime(true);
$startAt = hrtime(true);

$callback(...$parameters);

$time = $this->diff(hrtime(true), $startAt);
$memory = $this->memory->diff($memoryFrom);
$time = $this->diff(hrtime(true), $startAt);
$memory = $this->memory->diff($memoryFrom);

return [$time, $memory];
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use DragonCode\Benchmark\View\View;
use PHPUnit\Framework\TestCase;

Expand Down