1
0
Fork 0

some micro-optimizations made

refs issue #3657
pull/3685/head
Xavier Fornes 2015-01-28 14:43:58 +01:00
parent a4ffda699f
commit 2936dc0e55
1 changed files with 5 additions and 10 deletions

View File

@ -96,16 +96,11 @@ class ConsoleIO extends BaseIO
public function write($messages, $newline = true) public function write($messages, $newline = true)
{ {
if (null !== $this->startTime) { if (null !== $this->startTime) {
$messages = (array) $messages; $memoryUsage = memory_get_usage() / 1024 / 1024;
$startTime = $this->startTime; $timeSpent = microtime(true) - $this->startTime;
$messages = array_map(function ($message) use ($startTime) { $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
return sprintf( return sprintf('[%.1fMB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
'[%.1fMB/%.2fs] %s', }, (array) $messages);
memory_get_usage() / 1024 / 1024,
microtime(true) - $startTime,
$message
);
}, $messages);
} }
$this->output->write($messages, $newline); $this->output->write($messages, $newline);
$this->lastMessage = join($newline ? "\n" : '', (array) $messages); $this->lastMessage = join($newline ? "\n" : '', (array) $messages);