Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
MemoryDataCollector.php
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 implements LateDataCollectorInterface
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 * {@inheritdoc}
042 */
043 public function lateCollect()
044 {
045 $this->updateMemoryUsage();
046 }
047
048 /**
049 * Gets the memory.
050 *
051 * @return int The memory
052 */
053 public function getMemory()
054 {
055 return $this->data['memory'];
056 }
057
058 /**
059 * Gets the PHP memory limit.
060 *
061 * @return int The memory limit
062 */
063 public function getMemoryLimit()
064 {
065 return $this->data['memory_limit'];
066 }
067
068 /**
069 * Updates the memory usage data.
070 */
071 public function updateMemoryUsage()
072 {
073 $this->data['memory'] = memory_get_peak_usage(true);
074 }
075
076 /**
077 * {@inheritdoc}
078 */
079 public function getName()
080 {
081 return 'memory';
082 }
083
084 private function convertToBytes($memoryLimit)
085 {
086 if ('-1' === $memoryLimit) {
087 return -1;
088 }
089
090 $memoryLimit = strtolower($memoryLimit);
091 $max = strtolower(ltrim($memoryLimit, '+'));
092 if (0 === strpos($max, '0x')) {
093 $max = intval($max, 16);
094 } elseif (0 === strpos($max, '0')) {
095 $max = intval($max, 8);
096 } else {
097 $max = (int) $max;
098 }
099
100 switch (substr($memoryLimit, -1)) {
101 case 't': $max *= 1024;
102 case 'g': $max *= 1024;
103 case 'm': $max *= 1024;
104 case 'k': $max *= 1024;
105 }
106
107 return $max;
108 }
109 }
110