Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

MemoryDataCollector.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.15 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011   
 012  namespace Symfony\Component\HttpKernel\DataCollector;
 013   
 014  use Symfony\Component\HttpFoundation\Request;
 015  use Symfony\Component\HttpFoundation\Response;
 016   
 017  /**
 018   * MemoryDataCollector.
 019   *
 020   * @author Fabien Potencier <fabien@symfony.com>
 021   */
 022  class MemoryDataCollector extends DataCollector
 023  {
 024      public function __construct()
 025      {
 026          $this->data = array(
 027              'memory'       => 0,
 028              'memory_limit' => $this->convertToBytes(ini_get('memory_limit')),
 029          );
 030      }
 031   
 032      /**
 033       * {@inheritdoc}
 034       */
 035      public function collect(Request $request, Response $response, \Exception $exception = null)
 036      {
 037          $this->updateMemoryUsage();
 038      }
 039   
 040      /**
 041       * Gets the memory.
 042       *
 043       * @return int     The memory
 044       */
 045      public function getMemory()
 046      {
 047          return $this->data['memory'];
 048      }
 049   
 050      /**
 051       * Gets the PHP memory limit.
 052       *
 053       * @return int     The memory limit
 054       */
 055      public function getMemoryLimit()
 056      {
 057          return $this->data['memory_limit'];
 058      }
 059   
 060      /**
 061       * Updates the memory usage data.
 062       */
 063      public function updateMemoryUsage()
 064      {
 065          $this->data['memory'] = memory_get_peak_usage(true);
 066      }
 067   
 068      /**
 069       * {@inheritdoc}
 070       */
 071      public function getName()
 072      {
 073          return 'memory';
 074      }
 075   
 076      private function convertToBytes($memoryLimit)
 077      {
 078          if ('-1' === $memoryLimit) {
 079              return -1;
 080          }
 081   
 082          $memoryLimit = strtolower($memoryLimit);
 083          $max = strtolower(ltrim($memoryLimit, '+'));
 084          if (0 === strpos($max, '0x')) {
 085              $max = intval($max, 16);
 086          } elseif (0 === strpos($max, '0')) {
 087              $max = intval($max, 8);
 088          } else {
 089              $max = intval($max);
 090          }
 091   
 092          switch (substr($memoryLimit, -1)) {
 093              case 't': $max *= 1024;
 094              case 'g': $max *= 1024;
 095              case 'm': $max *= 1024;
 096              case 'k': $max *= 1024;
 097          }
 098   
 099          return $max;
 100      }
 101  }
 102