diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 0406d647edac..386d9bfefcf8 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -429,7 +429,7 @@ protected function presentStats(OutputInterface $output) { $output->writeln(""); $headers = [ - 'Folders', 'Files', 'Elapsed time' + 'Folders', 'Files', 'Elapsed time', 'Items per second' ]; $this->showSummary($headers, null, $output); @@ -444,11 +444,13 @@ protected function presentStats(OutputInterface $output) { */ protected function showSummary($headers, $rows, OutputInterface $output) { $niceDate = $this->formatExecTime(); + $itemsPerSecond = $this->getItemsPerSecond(); if (!$rows) { $rows = [ $this->foldersCounter, $this->filesCounter, $niceDate, + $itemsPerSecond ]; } $table = new Table($output); @@ -458,6 +460,22 @@ protected function showSummary($headers, $rows, OutputInterface $output) { $table->render(); } + /** + * Get items per second processed, no fractions + * + * @return string + */ + protected function getItemsPerSecond() { + $items = $this->foldersCounter + $this->filesCounter; + if ($this->execTime === 0) { + // catch div by 0 + $itemsPerSecond = 0; + } else { + $itemsPerSecond = $items / $this->execTime; + } + return \sprintf("%.0f", $itemsPerSecond); + } + /** * Formats microtime into a human readable format *