diff --git a/src/Command/CreateProductionCommand.php b/src/Command/CreateProductionCommand.php index 7145d14..e2a827c 100644 --- a/src/Command/CreateProductionCommand.php +++ b/src/Command/CreateProductionCommand.php @@ -123,18 +123,9 @@ class CreateProductionCommand extends Command } printf(" OK (%d)\n", count($knownTerms)); - $total = count($knownTerms); - $i = 0; - foreach ($allNotes as $note) { - $i += 1; - if ($i % 12 === 0 or $i === $total) { - printf( - "\33[2K\r% 7d/% 7d | %.2f GiB | Getting frequencies", - $i, - $total, - memory_get_usage() / 1024 / 1024 / 1024 - ); - } + $progress = new Progress('Getting frequenciees', count($allSentenceNotes)); + foreach ($allSentenceNotes as $note) { + $progress->tick(); assert($note instanceof SentenceNote); diff --git a/src/Utils/Progress.php b/src/Utils/Progress.php new file mode 100644 index 0000000..e8e971f --- /dev/null +++ b/src/Utils/Progress.php @@ -0,0 +1,26 @@ +i += 1; + if ($this->i % $this->speed === 0 or $this->i === $this->total) { + printf( + "\33[2K\r% 7d/% 7d | %.2f GiB | {$this->message}", + $this->i, + $this->total, + memory_get_usage() / 1024 / 1024 / 1024 + ); + } + } +}