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
32 changes: 8 additions & 24 deletions src/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public function __construct(
protected DeviationService $deviation = new DeviationService,
) {}

/**
* Creates a new benchmark instance.
*/
/** Creates a new benchmark instance. */
public static function make(): static
{
return new static;
Expand Down Expand Up @@ -178,9 +176,7 @@ public function toData(): array
return $this->mapResult();
}

/**
* Outputs benchmark results to the console as a table.
*/
/** Outputs benchmark results to the console as a table. */
public function toConsole(): void
{
if (! $data = $this->toData()) {
Expand All @@ -194,9 +190,7 @@ public function toConsole(): void
);
}

/**
* Returns the assertion service for performing result checks.
*/
/** Returns the assertion service for performing result checks. */
public function toAssert(): AssertService
{
if (! $data = $this->toData()) {
Expand All @@ -206,29 +200,23 @@ public function toAssert(): AssertService
return new AssertService($data);
}

/**
* Performs the benchmark: simple comparison or with deviation calculation.
*/
/** Performs the benchmark: simple comparison or with deviation calculation. */
protected function perform(): void
{
$this->deviations === 1
? $this->performCompare()
: $this->performDeviation();
}

/**
* Transforms collected data into an array of results.
*/
/** Transforms collected data into an array of results. */
protected function mapResult(): array
{
return $this->result->get(
$this->collector->all()
);
}

/**
* Performs a simple comparison of callback functions.
*/
/** Performs a simple comparison of callback functions. */
protected function performCompare(): void
{
$callbacks = $this->callbacks->compare;
Expand All @@ -239,9 +227,7 @@ protected function performCompare(): void
);
}

/**
* Performs a comparison with deviation calculation through multiple runs.
*/
/** Performs a comparison with deviation calculation through multiple runs. */
protected function performDeviation(): void
{
$results = [];
Expand Down Expand Up @@ -357,9 +343,7 @@ protected function push(mixed $name, float $time, float $memory): void
$this->collector->push($name, [$time, $memory]);
}

/**
* Clears results and collected data.
*/
/** Clears results and collected data. */
protected function clear(): void
{
$this->result->clear();
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/NoComparisonsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

class NoComparisonsException extends RuntimeException
{
/**
* Creates an exception indicating that the "compare" method was not called.
*/
/** Creates an exception indicating that the "compare" method was not called. */
public function __construct()
{
parent::__construct('Method "compare" was not called. No comparisons were made.');
Expand Down
8 changes: 2 additions & 6 deletions src/Services/CollectorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@ public function push(int|string $name, array $values): static
return $this;
}

/**
* Returns all collected measurement data.
*/
/** Returns all collected measurement data. */
public function all(): array
{
return $this->data;
}

/**
* Clears all collected data.
*/
/** Clears all collected data. */
public function clear(): void
{
$this->data = [];
Expand Down
4 changes: 1 addition & 3 deletions src/Services/MemoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public function diff(int $memory): int
return memory_get_peak_usage(true) - $memory;
}

/**
* Resets peak memory usage and runs the garbage collector.
*/
/** Resets peak memory usage and runs the garbage collector. */
public function reset(): void
{
gc_collect_cycles();
Expand Down
8 changes: 2 additions & 6 deletions src/Services/ResultService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public function __construct(
protected MeasurementErrorService $measurement = new MeasurementErrorService,
) {}

/**
* Checks whether results have already been calculated.
*/
/** Checks whether results have already been calculated. */
public function has(): bool
{
return $this->data !== null;
Expand All @@ -51,9 +49,7 @@ public function get(array $collections): array
return $this->data ??= $this->map($collections);
}

/**
* Clears the stored results.
*/
/** Clears the stored results. */
public function clear(): void
{
$this->data = null;
Expand Down
4 changes: 1 addition & 3 deletions src/Services/RunnerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public function call(Closure $callback, array $parameters = []): array
return $this->run($callback, $parameters);
}

/**
* Resets the memory state before measurement.
*/
/** Resets the memory state before measurement. */
protected function clean(): void
{
$this->memory->reset();
Expand Down
8 changes: 2 additions & 6 deletions src/Services/ViewService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public function __construct(
protected SilentProgressBarView $silentProgressBar = new SilentProgressBarView,
) {}

/**
* @return $this
*/
/** @return $this */
public function disable(): static
{
$this->enabled = false;
Expand All @@ -41,9 +39,7 @@ public function table(array $data): void
$this->table->show($data);
}

/**
* Returns the progress bar instance.
*/
/** Returns the progress bar instance. */
public function progressBar(): ProgressBar
{
return $this->enabled
Expand Down
8 changes: 2 additions & 6 deletions src/View/ProgressBarView.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public function advance(int $step = 1): void
$this->display();
}

/**
* Finishes the progress bar by setting the current value equal to the total.
*/
/** Finishes the progress bar by setting the current value equal to the total. */
public function finish(): void
{
$this->current = $this->total;
Expand All @@ -59,9 +57,7 @@ public function finish(): void
$this->write(PHP_EOL);
}

/**
* Renders the current state of the progress bar.
*/
/** Renders the current state of the progress bar. */
protected function display(): void
{
$percent = $this->percent();
Expand Down