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
19 changes: 1 addition & 18 deletions src/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public function __construct(

/**
* Creates a new benchmark instance.
*
* @return static
*/
public static function make(): static
{
Expand All @@ -50,7 +48,6 @@ public static function make(): static
* Sets a callback to be executed before all iterations for each comparison.
*
* @param Closure(int|string $name): mixed $callback
*
* @return $this
*/
public function before(Closure $callback): static
Expand All @@ -64,7 +61,6 @@ public function before(Closure $callback): static
* Sets a callback to be executed before each iteration.
*
* @param Closure(int|string $name, int<1, max> $iteration): mixed $callback
*
* @return $this
*/
public function beforeEach(Closure $callback): static
Expand All @@ -78,7 +74,6 @@ public function beforeEach(Closure $callback): static
* Sets a callback to be executed after all iterations for each comparison.
*
* @param Closure(int|string $name): mixed $callback
*
* @return $this
*/
public function after(Closure $callback): static
Expand All @@ -92,7 +87,6 @@ public function after(Closure $callback): static
* Sets a callback to be executed after each iteration.
*
* @param Closure(int|string $name, int<1, max> $iteration, float $time, float $memory): mixed $callback
*
* @return $this
*/
public function afterEach(Closure $callback): static
Expand All @@ -106,7 +100,6 @@ public function afterEach(Closure $callback): static
* Sets the number of iterations for each comparison.
*
* @param int<1, max> $count
*
* @return $this
*/
public function iterations(int $count): static
Expand All @@ -120,7 +113,6 @@ public function iterations(int $count): static
* Enables deviation calculation and sets the number of runs.
*
* @param int<2, max> $count
*
* @return $this
*/
public function deviations(int $count = 2): static
Expand All @@ -136,7 +128,6 @@ public function deviations(int $count = 2): static
* Sets the rounding precision for time values.
*
* @param int<0, max>|null $precision The number of decimal places. Null means no rounding.
*
* @return $this
*/
public function round(?int $precision): static
Expand All @@ -162,7 +153,6 @@ public function disableProgressBar(): static
* Registers callback functions for comparison.
*
* @param array|Closure ...$callbacks Callback functions or an array of callback functions for comparison.
*
* @return $this
*/
public function compare(array|Closure ...$callbacks): static
Expand Down Expand Up @@ -206,8 +196,6 @@ public function toConsole(): void

/**
* Returns the assertion service for performing result checks.
*
* @return AssertService
*/
public function toAssert(): AssertService
{
Expand All @@ -230,8 +218,6 @@ protected function perform(): void

/**
* Transforms collected data into an array of results.
*
* @return array
*/
protected function mapResult(): array
{
Expand Down Expand Up @@ -302,8 +288,6 @@ protected function withProgress(Closure $callback, int $total): void
*
* @param array $callbacks An array of callback functions.
* @param int $multiplier The multiplier (number of runs).
*
* @return int
*/
protected function steps(array $callbacks, int $multiplier = 1): int
{
Expand Down Expand Up @@ -354,8 +338,7 @@ protected function run(mixed $name, Closure $callback, ProgressBarView $progress
*
* @param Closure $callback The callback function to execute.
* @param array $parameters Parameters to pass to the callback.
*
* @return array An array [time in milliseconds, memory in bytes].
* @return array An array [time in milliseconds, memory in bytes].
*/
protected function call(Closure $callback, array $parameters = []): array
{
Expand Down
12 changes: 0 additions & 12 deletions src/Services/AssertService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function __construct(
*
* @param float|null $from Start value is specified in milliseconds.
* @param float|null $till End value is specified in milliseconds.
*
* @return $this
*/
public function toBeMinTime(?float $from = null, ?float $till = null): static
Expand All @@ -43,7 +42,6 @@ public function toBeMinTime(?float $from = null, ?float $till = null): static
*
* @param float|null $from Start value is specified in milliseconds.
* @param float|null $till End value is specified in milliseconds.
*
* @return $this
*/
public function toBeMaxTime(?float $from = null, ?float $till = null): static
Expand All @@ -63,7 +61,6 @@ public function toBeMaxTime(?float $from = null, ?float $till = null): static
*
* @param float|null $from Start value is specified in milliseconds.
* @param float|null $till End value is specified in milliseconds.
*
* @return $this
*/
public function toBeAvgTime(?float $from = null, ?float $till = null): static
Expand All @@ -83,7 +80,6 @@ public function toBeAvgTime(?float $from = null, ?float $till = null): static
*
* @param float|null $from Start value is specified in milliseconds.
* @param float|null $till End value is specified in milliseconds.
*
* @return $this
*/
public function toBeTotalTime(?float $from = null, ?float $till = null): static
Expand All @@ -103,7 +99,6 @@ public function toBeTotalTime(?float $from = null, ?float $till = null): static
*
* @param float|null $from Start value is specified in bytes.
* @param float|null $till End value is specified in bytes.
*
* @return $this
*/
public function toBeMinMemory(?float $from = null, ?float $till = null): static
Expand All @@ -123,7 +118,6 @@ public function toBeMinMemory(?float $from = null, ?float $till = null): static
*
* @param float|null $from Start value is specified in bytes.
* @param float|null $till End value is specified in bytes.
*
* @return $this
*/
public function toBeMaxMemory(?float $from = null, ?float $till = null): static
Expand All @@ -143,7 +137,6 @@ public function toBeMaxMemory(?float $from = null, ?float $till = null): static
*
* @param float|null $from Start value is specified in bytes.
* @param float|null $till End value is specified in bytes.
*
* @return $this
*/
public function toBeAvgMemory(?float $from = null, ?float $till = null): static
Expand All @@ -163,7 +156,6 @@ public function toBeAvgMemory(?float $from = null, ?float $till = null): static
*
* @param float|null $from Start value is specified in bytes.
* @param float|null $till End value is specified in bytes.
*
* @return $this
*/
public function toBeTotalMemory(?float $from = null, ?float $till = null): static
Expand All @@ -183,7 +175,6 @@ public function toBeTotalMemory(?float $from = null, ?float $till = null): stati
*
* @param float|null $from Start value is specified in percentages.
* @param float|null $till End value is specified in percentages.
*
* @return $this
*/
public function toBeDeviationTime(?float $from = null, ?float $till = null): static
Expand All @@ -207,7 +198,6 @@ public function toBeDeviationTime(?float $from = null, ?float $till = null): sta
*
* @param float|null $from Start value is specified in percentages.
* @param float|null $till End value is specified in percentages.
*
* @return $this
*/
public function toBeDeviationMemory(?float $from = null, ?float $till = null): static
Expand Down Expand Up @@ -275,8 +265,6 @@ protected function assertLessThan(float $actual, ?float $expected, string $name)
*
* @param float|null $from The start value of the range.
* @param float|null $till The end value of the range.
*
* @return float|null
*/
protected function resolveFrom(?float $from, ?float $till): ?float
{
Expand Down
4 changes: 1 addition & 3 deletions src/Services/CallbacksService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CallbacksService
* Registers callback functions for comparison.
*
* @param array<int|string, Closure>|Closure ...$callbacks Callback functions or an array of callback functions
* for comparison.
* for comparison.
*/
public function compare(array|Closure ...$callbacks): void
{
Expand Down Expand Up @@ -100,8 +100,6 @@ protected function perform(?Closure $callback, mixed ...$args): mixed
* Extracts parameters from callback functions.
*
* @param array $callbacks An array of callback functions.
*
* @return array
*/
protected function parameters(array $callbacks): array
{
Expand Down
3 changes: 0 additions & 3 deletions src/Services/CollectorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class CollectorService
*
* @param int|string $name The callback name.
* @param array $values An array of values [time in milliseconds, memory in bytes].
*
* @return $this
*/
public function push(int|string $name, array $values): static
Expand All @@ -25,8 +24,6 @@ public function push(int|string $name, array $values): static

/**
* Returns all collected measurement data.
*
* @return array
*/
public function all(): array
{
Expand Down
17 changes: 1 addition & 16 deletions src/Services/DeviationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function __construct(
* Calculates final results with deviations based on multiple runs.
*
* @param array<int, array<int|string, ResultData>> $collection A collection of results from multiple runs.
*
* @return array<int|string, ResultData>
*/
public function calculate(array $collection): array
Expand All @@ -37,7 +36,6 @@ public function calculate(array $collection): array
* Transforms grouped data into an array of ResultData.
*
* @param array $collection Grouped measurement data.
*
* @return array<int|string, ResultData>
*/
protected function map(array $collection): array
Expand All @@ -49,8 +47,6 @@ protected function map(array $collection): array
* Creates a ResultData object with metrics and deviations from grouped data.
*
* @param array $item Grouped data for a single callback.
*
* @return ResultData
*/
protected function make(array $item): ResultData
{
Expand All @@ -68,8 +64,6 @@ protected function make(array $item): ResultData
*
* @param array $item Grouped data for a single callback.
* @param string $key The metric key (min, max, avg, total).
*
* @return MetricData
*/
protected function metric(array $item, string $key): MetricData
{
Expand All @@ -83,8 +77,6 @@ protected function metric(array $item, string $key): MetricData
* Calculates deviation data based on average values.
*
* @param array $item Grouped data for a single callback.
*
* @return DeviationData
*/
protected function deviationMetric(array $item): DeviationData
{
Expand All @@ -106,8 +98,6 @@ protected function deviationMetric(array $item): DeviationData
*
* @param float $time Time value is specified in milliseconds.
* @param float $memory Memory value is specified in bytes.
*
* @return MetricData
*/
protected function metricData(float $time, float $memory): MetricData
{
Expand All @@ -118,8 +108,6 @@ protected function metricData(float $time, float $memory): MetricData
* Groups results from multiple runs by callback names and metric types.
*
* @param array $collection A collection of results from multiple runs.
*
* @return array
*/
protected function flatten(array $collection): array
{
Expand All @@ -141,8 +129,6 @@ protected function flatten(array $collection): array
* Calculates the standard deviation for an array of values.
*
* @param array $values An array of numeric values.
*
* @return float
*/
protected function deviation(array $values): float
{
Expand All @@ -160,8 +146,7 @@ protected function deviation(array $values): float
*
* @param float $value1 The base value.
* @param float $value2 The compared value.
*
* @return float The result is specified in percentages.
* @return float The result is specified in percentages.
*/
protected function percentage(float $value1, float $value2): float
{
Expand Down
13 changes: 1 addition & 12 deletions src/Services/MeasurementErrorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class MeasurementErrorService
* Filters data by discarding extreme values to reduce measurement error.
*
* @param array $data An array of numeric measurement values.
*
* @return array The filtered array of values.
* @return array The filtered array of values.
*/
public function filter(array $data): array
{
Expand All @@ -37,8 +36,6 @@ public function filter(array $data): array
*
* @param array $data An array of numeric values.
* @param int $count The number of elements in the array.
*
* @return array
*/
protected function partial(array $data, int $count): array
{
Expand All @@ -54,8 +51,6 @@ protected function partial(array $data, int $count): array
* Calculates the offset for discarding extreme values.
*
* @param int $count The number of elements in the array.
*
* @return int
*/
protected function offset(int $count): int
{
Expand All @@ -66,8 +61,6 @@ protected function offset(int $count): int
* Calculates the number of elements to keep after filtering.
*
* @param int $count The number of elements in the array.
*
* @return int
*/
protected function take(int $count): int
{
Expand All @@ -78,8 +71,6 @@ protected function take(int $count): int
* Checks whether filtering is disabled due to insufficient data.
*
* @param int $count The number of elements in the array.
*
* @return bool
*/
protected function disabled(int $count): bool
{
Expand All @@ -90,8 +81,6 @@ protected function disabled(int $count): bool
* Sorts the array of values in ascending order.
*
* @param array $values An array of numeric values.
*
* @return array
*/
protected function sort(array $values): array
{
Expand Down
8 changes: 3 additions & 5 deletions src/Services/MemoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MemoryService
/**
* Returns the current peak memory usage.
*
* @return int The value is specified in bytes.
* @return int The value is specified in bytes.
*/
public function now(): int
{
Expand All @@ -32,8 +32,7 @@ public function now(): int
* Calculates the difference between the current peak memory usage and the provided value.
*
* @param int $memory The initial memory value is specified in bytes.
*
* @return int The difference is specified in bytes.
* @return int The difference is specified in bytes.
*/
public function diff(int $memory): int
{
Expand All @@ -53,8 +52,7 @@ public function reset(): void
* Formats a memory value into a human-readable format.
*
* @param int $bytes The memory value is specified in bytes.
*
* @return string A formatted string (e.g., "1.50 MB").
* @return string A formatted string (e.g., "1.50 MB").
*/
public function format(int $bytes): string
{
Expand Down
Loading