mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-07-25 10:41:55 +02:00
allow customization of the memory precision (#530)
currently there is no way to see the raw "peak_usage" bytes in the output. I'd love to have that number available somewhere, but I couldn't figure out how to do that. this change is the next best thing, as it allows us to override the default precision of "0", so we can get a little more granularity into the memory usage.
This commit is contained in:
@@ -23,6 +23,18 @@ class MemoryCollector extends DataCollector implements Renderable
|
||||
|
||||
protected $peakUsage = 0;
|
||||
|
||||
protected $precision = 0;
|
||||
|
||||
/**
|
||||
* Set the precision of the 'peak_usage_str' output.
|
||||
*
|
||||
* @param int $precision
|
||||
*/
|
||||
public function setPrecision($precision)
|
||||
{
|
||||
$this->precision = $precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether total allocated memory page size is used instead of actual used memory size
|
||||
* by the application. See $real_usage parameter on memory_get_peak_usage for details.
|
||||
@@ -82,7 +94,7 @@ class MemoryCollector extends DataCollector implements Renderable
|
||||
$this->updatePeakUsage();
|
||||
return array(
|
||||
'peak_usage' => $this->getPeakUsage(),
|
||||
'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->getPeakUsage(), 0)
|
||||
'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->getPeakUsage(), $this->precision)
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user