Skip to content

Commit

Permalink
Merge pull request #32089 from owncloud/add_ops_per_second
Browse files Browse the repository at this point in the history
files:scan add number of items per second on printed result table
  • Loading branch information
phil-davis authored Jul 19, 2018
2 parents 33a4c4c + 0b8edef commit 7dc775b
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 @@ -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);
Expand All @@ -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);
Expand All @@ -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
*
Expand Down

0 comments on commit 7dc775b

Please sign in to comment.