diff --git a/src/Command/BenchmarkCommand.php b/src/Command/BenchmarkCommand.php index 813c0bb9a..fedd73acd 100644 --- a/src/Command/BenchmarkCommand.php +++ b/src/Command/BenchmarkCommand.php @@ -50,15 +50,21 @@ public function execute(Arguments $args, ConsoleIo $io): ?int $this->io = $io; /** @var string $url */ $url = $args->getArgumentAt(0); - $defaults = ['t' => 100, 'n' => 10]; - $options = array_merge($defaults, $args->getOptions()); $times = []; $io->out(Text::insert('-> Testing :url', compact('url'))); $io->out(''); - for ($i = 0; $i < $options['n']; $i++) { - /** @psalm-suppress PossiblyInvalidOperand */ - if (floor($options['t'] - array_sum($times)) <= 0 || $options['n'] <= 1) { + $count = 10; + if ($args->hasOption('n')) { + $count = (float)$args->getOption('n'); + } + $timeout = 100; + if ($args->hasOption('t')) { + $timeout = (float)$args->getOption('t'); + } + + for ($i = 0; $i < $count; $i++) { + if (floor($timeout - array_sum($times)) <= 0 || $count <= 1) { break; }