From 5ff10b4e95327589739fc32cfe8863194887cc37 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 19 Jul 2018 10:06:04 +0200 Subject: [PATCH] [stable10] files:scan : add number of items per second on printed result --- apps/files/lib/Command/Scan.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 850dc1c7e4fb..e8a9356015d6 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -428,7 +428,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); @@ -443,11 +443,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) { } + /** + * 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 *