diff --git a/src/CLI/Command/Check.php b/src/CLI/Command/Check.php index d8cb513d..16621922 100644 --- a/src/CLI/Command/Check.php +++ b/src/CLI/Command/Check.php @@ -66,6 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { ini_set('memory_limit', '-1'); ini_set('xdebug.max_nesting_level', '10000'); + $startTime = microtime(true); try { $verbose = $input->getOption('verbose'); @@ -94,6 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $violations = $runner->getViolations(); if ($violations->count() > 0) { $this->printViolations($violations, $output); + $this->printExecutionTime($output, $startTime); return self::ERROR_CODE; } @@ -101,16 +103,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int $parsedErrors = $runner->getParsingErrors(); if ($parsedErrors->count() > 0) { $this->printParsedErrors($parsedErrors, $output); + $this->printExecutionTime($output, $startTime); return self::ERROR_CODE; } } catch (\Throwable $e) { $output->writeln($e->getMessage()); + $this->printExecutionTime($output, $startTime); return self::ERROR_CODE; } $this->printNoViolationsDetectedMessage($output); + $this->printExecutionTime($output, $startTime); return self::SUCCESS_CODE; } @@ -136,6 +141,14 @@ protected function printHeadingLine(OutputInterface $output): void $output->writeln("PHPArkitect $version\n"); } + protected function printExecutionTime(OutputInterface $output, float $startTime): void + { + $endTime = microtime(true); + $executionTime = number_format($endTime - $startTime, 2); + + $output->writeln('Execution time: '.$executionTime."s\n"); + } + private function getConfigFilename(InputInterface $input): string { $filename = $input->getOption(self::CONFIG_FILENAME_PARAM);