/** * Constructor * @param int $memoryUsage memory used * @param int $memoryPeakUsage memory peak * @param int $padPositionX x position of the pad in the main screen * @param int $padPositionY y position of the pad in the main screen */ public function __construct($memoryUsage, $memoryPeakUsage, $padPositionX, $padPositionY) { parent::__construct($padPositionX, $padPositionY); $this->memoryUsage = UnitFormatter::formatByte($memoryUsage); $this->memoryPeak = UnitFormatter::formatByte($memoryPeakUsage); $this->memoryLimit = ini_get("memory_limit"); if (-1 == $this->memoryLimit) { $this->memoryLimit = "-1 (no limit)"; } }
/** * Returns the memory usage HTML code */ protected function getMemoryUsageHtml() { $memory = UnitFormatter::formatByte($this->getMemoryUsage()); $memoryPeak = UnitFormatter::formatByte($this->getMemoryPeakUsage()); $memoryLimit = ini_get("memory_limit"); if (-1 == $memoryLimit) { $memoryLimit = "-1 (no limit)"; } $content = "\n <div class='exceptionRenderMemoryUsage'>\n <strong>Memory used</strong>\n {$memory}\n </div>\n <div class='exceptionRenderMemoryUsage'>\n <strong>Memory peak</strong>\n {$memoryPeak}\n </div>\n <div class='exceptionRenderMemoryUsage'>\n <strong>Limit</strong>\n {$memoryLimit}\n </div>\n "; return $this->cat("Memory Usage", $content); }
/** * Shows memory usage */ protected function showMemoryUsage() { $memory = UnitFormatter::formatByte($this->getMemoryUsage()); $memoryPeak = UnitFormatter::formatByte($this->getMemoryPeakUsage()); $memoryLimit = ini_get("memory_limit"); if (-1 == $memoryLimit) { $memoryLimit = "-1 (no limit)"; } $this->openCat("Memory Usage"); $this->firePhp->log("Memory used : {$memory}"); $this->firePhp->log("Memory peak : {$memoryPeak}"); $this->firePhp->log("Memory limit : {$memoryLimit}"); $this->closeCat(); }
/** * {@inheritdoc} */ public function getEndPeakMemoryUsage($formatted = false) { if ($formatted && $this->endPeakMemoryUsage) { return UnitFormatter::formatByte($this->endPeakMemoryUsage); } elseif ($this->endPeakMemoryUsage) { return $this->endPeakMemoryUsage; } else { return false; } }