-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
added memory usage to console progress helper #9573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ class ProgressHelper extends Helper | |
{ | ||
const FORMAT_QUIET = ' %percent%%'; | ||
const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%'; | ||
const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%'; | ||
const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed% (%memory%)'; | ||
const FORMAT_QUIET_NOMAX = ' %current%'; | ||
const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]'; | ||
const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%'; | ||
|
@@ -76,6 +76,7 @@ class ProgressHelper extends Helper | |
'bar', | ||
'percent', | ||
'elapsed', | ||
'memory' | ||
); | ||
|
||
/** | ||
|
@@ -95,6 +96,7 @@ class ProgressHelper extends Helper | |
'max' => 4, | ||
'percent' => 3, | ||
'elapsed' => 6, | ||
'memory' => 6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Miss trailing comma. |
||
); | ||
|
||
/** | ||
|
@@ -392,9 +394,38 @@ private function generate($finish = false) | |
$vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT); | ||
} | ||
|
||
if (isset($this->formatVars['memory'])) { | ||
$vars['memory'] = str_pad($this->humaneMemory(), $this->widths['memory'], ' ', STR_PAD_LEFT); | ||
} | ||
|
||
return $vars; | ||
} | ||
|
||
/** | ||
* Converts memory usage to human-readable format. | ||
* | ||
* @return string | ||
*/ | ||
private function humaneMemory() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: humanMemory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just took the "name" from the method just below called "humaneTime" |
||
{ | ||
$memory = memory_get_usage(true); | ||
|
||
if ($memory > 1024*1024*1024*10) { | ||
return sprintf('%.2fGB', $memory/1024/1024/1024); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more correct would be |
||
} | ||
|
||
if ($memory > 1024*1024*10) { | ||
return sprintf('%.2fMB', $memory/1024/1024); | ||
} | ||
|
||
if ($memory > 1024*10) { | ||
return sprintf('%.2fkB', $memory/1024); | ||
} | ||
|
||
return sprintf('%.2fB', $memory); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this line break |
||
} | ||
|
||
/** | ||
* Converts seconds into human-readable format. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miss trailing comma.