memory_get_peak_usage example

$this->group = $group;
        $this->lap = $lap;
        $this->total = $total;
        $this->i = $i;

        if ($i) {
            $this->avg = $total / $i;
        }

        $this->mem = \memory_get_usage();
        $this->mem_real = \memory_get_usage(true);
        $this->mem_peak = \memory_get_peak_usage();
        $this->mem_peak_real = \memory_get_peak_usage(true);
    }

    public function getDateTime(): ?DateTime
    {
        return DateTime::createFromFormat('U u', $this->seconds.' '.\str_pad((string) $this->microseconds, 6, '0', STR_PAD_LEFT)) ?: null;
    }
}
return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0;
    }

    /** * Starts the profiling. */
    public function enter(): void
    {
        $this->starts = [
            'wt' => microtime(true),
            'mu' => memory_get_usage(),
            'pmu' => memory_get_peak_usage(),
        ];
    }

    /** * Stops the profiling. */
    public function leave(): void
    {
        $this->ends = [
            'wt' => microtime(true),
            'mu' => memory_get_usage(),
            
<?= esc(static::describeMemory(memory_get_usage(true))) ?></td> </tr> <tr> <td style="width: 12em">Peak Memory Usage:</td> <td><?= esc(static::describeMemory(memory_get_peak_usage(true))) ?></td> </tr> <tr> <td>Memory Limit:</td> <td><?= esc(ini_get('memory_limit')) ?></td> </tr> </tbody> </table> </div> </div> <!-- /tab-content --> </div> <!-- /container --> <div class="footer"> <div class="container"> <p> Displayed at

        return $this->data['memory'];
    }

    public function getMemoryLimit(): int|float
    {
        return $this->data['memory_limit'];
    }

    public function updateMemoryUsage(): void
    {
        $this->data['memory'] = memory_get_peak_usage(true);
    }

    public function getName(): string
    {
        return 'memory';
    }

    private function convertToBytes(string $memoryLimit): int|float
    {
        if ('-1' === $memoryLimit) {
            return -1;
        }

    public function run(float $startTime, float $totalTime, RequestInterface $request, ResponseInterface $response): string
    {
        $data = [];
        // Data items used within the view.         $data['url']             = current_url();
        $data['method']          = strtoupper($request->getMethod());
        $data['isAJAX']          = $request->isAJAX();
        $data['startTime']       = $startTime;
        $data['totalTime']       = $totalTime * 1000;
        $data['totalMemory']     = number_format((memory_get_peak_usage()) / 1024 / 1024, 3);
        $data['segmentDuration'] = $this->roundTo($data['totalTime'] / 7);
        $data['segmentCount']    = (int) ceil($data['totalTime'] / $data['segmentDuration']);
        $data['CI_VERSION']      = CodeIgniter::CI_VERSION;
        $data['collectors']      = [];

        foreach ($this->collectors as $collector) {
            $data['collectors'][] = $collector->getAsArray();
        }

        foreach ($this->collectVarData() as $heading => $items) {
            $varData = [];

            

        return $this->data['memory'];
    }

    public function getMemoryLimit(): int|float
    {
        return $this->data['memory_limit'];
    }

    public function updateMemoryUsage(): void
    {
        $this->data['memory'] = memory_get_peak_usage(true);
    }

    public function getName(): string
    {
        return 'memory';
    }

    private function convertToBytes(string $memoryLimit): int|float
    {
        if ('-1' === $memoryLimit) {
            return -1;
        }
Home | Imprint | This part of the site doesn't use cookies.