Skip to content

Commit

Permalink
Use Debugger::convertSize to show memory
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Jan 29, 2022
1 parent 99bdd52 commit 1a2ddfd
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Debug/AppCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Framework\MVC\Debug;

use Framework\Debug\Collector;
use Framework\Debug\Debugger;
use Framework\MVC\App;
use ReflectionClass;
use ReflectionMethod;
Expand Down Expand Up @@ -101,7 +102,7 @@ public function getContents() : string
</p>
<p>
<strong>Memory:</strong> <?=
$this->convertSize($this->endMemory - $this->startMemory) ?>
Debugger::convertSize($this->endMemory - $this->startMemory) ?>
</p>
<h1>Services</h1>
<h2>Loaded Service Instances</h2>
Expand All @@ -112,13 +113,6 @@ public function getContents() : string
return \ob_get_clean(); // @phpstan-ignore-line
}

protected function convertSize(float | int $size) : string
{
$unit = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
$index = \floor(\log($size, 1024));
return \round($size / (1024 ** $index), 3) . ' ' . $unit[$index];
}

protected function renderLoadedServices() : string
{
$services = $this->getServices();
Expand Down

0 comments on commit 1a2ddfd

Please sign in to comment.