Skip to content

Commit

Permalink
[stable10] files:scan : add number of items per second on printed result
Browse files Browse the repository at this point in the history
  • Loading branch information
mmattel authored and gitmate-bot committed Jul 20, 2018
1 parent bc98c34 commit 5ff10b4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion apps/files/lib/Command/Scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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
*
Expand Down

0 comments on commit 5ff10b4

Please sign in to comment.