| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class Memory implements MemoryInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * $real=true shows allocated memory (-> system monitoring) |
||
| 21 | * $real=null|false shows memory used by script (-> memory leak search) |
||
| 22 | * Do not take PHP external resources into account (remote/DB connection, SimpleXML, etc) |
||
| 23 | * See http://drib.tech/programming/get-real-amount-memory-allocated-php. |
||
| 24 | * |
||
| 25 | * @param bool|null $real |
||
| 26 | * |
||
| 27 | * @return string |
||
| 28 | * @return string |
||
| 29 | */ |
||
| 30 | public function getMemory(?bool $real = null): string |
||
| 31 | { |
||
| 32 | return sprintf( |
||
| 33 | "Memory %s: %s %s \n", |
||
| 34 | ($real) ? '(true)' : '', |
||
| 35 | $this->memoryUsage(), |
||
| 36 | $this->memoryPeak() |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function memoryUsage(?bool $real = null): string |
||
| 45 | } |
||
| 46 | |||
| 47 | public function memoryPeak(?bool $real = null): string |
||
| 52 | } |
||
| 53 | |||
| 54 | private function convert(int $size): string |
||
| 59 | } |
||
| 60 | } |
||
| 61 |