| Total Complexity | 8 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class PerformanceMetrics |
||
| 12 | { |
||
| 13 | private readonly float $startTime; |
||
| 14 | |||
| 15 | private readonly int $startMemory; |
||
| 16 | |||
| 17 | public function __construct() |
||
| 18 | { |
||
| 19 | $this->startTime = microtime(true); |
||
|
|
|||
| 20 | $this->startMemory = memory_get_usage(true); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function getElapsedTime(): float |
||
| 24 | { |
||
| 25 | return microtime(true) - $this->startTime; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function getMemoryUsed(): int |
||
| 31 | } |
||
| 32 | |||
| 33 | public function formatElapsedTime(): string |
||
| 36 | } |
||
| 37 | |||
| 38 | public function formatMemoryUsed(): string |
||
| 39 | { |
||
| 40 | return $this->formatBytes($this->getMemoryUsed()); |
||
| 41 | } |
||
| 42 | |||
| 43 | private function formatBytes(int $bytes): string |
||
| 54 | } |
||
| 55 | } |
||
| 56 |