前置き
Symfony2.5 だと
Progress Bar (Symfony Console component)
↑こんな感じに、すごくいい感じでメモリを表示することができるけど、それ以下だと出来ないので
やっつけ的に
protected function execute(InputInterface $input, OutputInterface $output)
{
$tmpProgress = $this->getHelperSet()->get('progress');
$progress = function () use (&$tmpProgress) {
$tmpProgress->setFormat(
ProgressHelper::FORMAT_VERBOSE .
sprintf(
' Memory: %.2f MB / %.2f MB',
memory_get_usage(true) / 1024 / 1024,
memory_get_peak_usage(true) / 1024 / 1024
)
);
return $tmpProgress;
};
$max = 50;
$progress()->start($output, $max);
$i = 0;
$data = [];
while ($i++ < $max) {
$progress()->advance();
$data = array_merge($data, range(1, $i * 100));
}
$progress()->finish();
}
こんな感じで
$ ./app/console test
50/50 [============================] 100% Elapsed: 1 sec Memory: 53.00 MB / 54.25 MB
やったりすることもあった。でも効率悪そう。