Skip to content

Commit

Permalink
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 committed Jul 18, 2018
1 parent b161b20 commit 00ac0b8
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();
$items_per_second = $this->getItemsPerSecond();
if (!$rows) {
$rows = [
$this->foldersCounter,
$this->filesCounter,
$niceDate,
$items_per_second
];
}
$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
$items_per_second = 0;
} else {
$items_per_second = $items / $this->execTime;
}
return \sprintf("%.0f", $items_per_second);
}

/**
* Formats microtime into a human readable format
*
Expand Down

0 comments on commit 00ac0b8

Please sign in to comment.