Skip to content

Commit a3458b1

Browse files
Auto-disable output of detailed information for large volumes of processing
1 parent 9991324 commit a3458b1

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ Result example:
125125
----- ------------------- -------------------
126126
```
127127

128+
> Note
129+
>
130+
> If the option to display detailed information is enabled (without using the `withoutData` method) and more than 1000 iterations are requested, then the output of detailed
131+
> information will be forcibly disabled, since there will be absolutely no point in it with a significantly increasing load on the computer.
132+
128133
### Round Precision
129134

130135
By default, the script does not round measurement results, but you can specify the number of decimal places to which rounding can be performed.

src/Comparator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Comparator
2424
protected array $result = [];
2525

2626
public function __construct(
27-
protected Runner $runner = new Runner(),
27+
protected Runner $runner = new Runner(),
2828
protected Transformer $transformer = new Transformer()
2929
) {
3030
$this->view = new View(new SymfonyStyle(
@@ -109,14 +109,19 @@ protected function push(mixed $name, int $iteration, float $time): void
109109

110110
protected function show(): void
111111
{
112-
$table = $this->withData ? $this->transformer->forTime($this->result) : [];
112+
$table = $this->withData() ? $this->transformer->forTime($this->result) : [];
113113

114114
$stats = $this->transformer->forStats($this->result);
115115
$winner = $this->transformer->forWinners($stats);
116116

117117
$this->view->table($this->transformer->merge($table, $stats, $winner));
118118
}
119119

120+
protected function withData(): bool
121+
{
122+
return $this->withData && $this->iterations <= 1000;
123+
}
124+
120125
protected function validate(mixed $callback): void
121126
{
122127
if (! is_callable($callback)) {

0 commit comments

Comments
 (0)