From 00ac0b8f570e9bb1c3e38c136a945733e4f9bfc5 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 18 Jul 2018 21:16:17 +0200 Subject: [PATCH] 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 0406d647edac..eac1eee1505b 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(); + $items_per_second = $this->getItemsPerSecond(); if (!$rows) { $rows = [ $this->foldersCounter, $this->filesCounter, $niceDate, + $items_per_second ]; } $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 + $items_per_second = 0; + } else { + $items_per_second = $items / $this->execTime; + } + return \sprintf("%.0f", $items_per_second); + } + /** * Formats microtime into a human readable format *