Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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->reset();
027 }
028
029 /**
030 * {@inheritdoc}
031 */
032 public function collect(Request $request, Response $response, \Exception $exception = null)
033 {
034 $this->updateMemoryUsage();
035 }
036
037 /**
038 * {@inheritdoc}
039 */
040 public function reset()
041 {
042 $this->data = [
043 'memory' => 0,
044 'memory_limit' => $this->convertToBytes(ini_get('memory_limit')),
045 ];
046 }
047
048 /**
049 * {@inheritdoc}
050 */
051 public function lateCollect()
052 {
053 $this->updateMemoryUsage();
054 }
055
056 /**
057 * Gets the memory.
058 *
059 * @return int The memory
060 */
061 public function getMemory()
062 {
063 return $this->data['memory'];
064 }
065
066 /**
067 * Gets the PHP memory limit.
068 *
069 * @return int The memory limit
070 */
071 public function getMemoryLimit()
072 {
073 return $this->data['memory_limit'];
074 }
075
076 /**
077 * Updates the memory usage data.
078 */
079 public function updateMemoryUsage()
080 {
081 $this->data['memory'] = memory_get_peak_usage(true);
082 }
083
084 /**
085 * {@inheritdoc}
086 */
087 public function getName()
088 {
089 return 'memory';
090 }
091
092 private function convertToBytes($memoryLimit)
093 {
094 if ('-1' === $memoryLimit) {
095 return -1;
096 }
097
098 $memoryLimit = strtolower($memoryLimit);
099 $max = strtolower(ltrim($memoryLimit, '+'));
100 if (0 === strpos($max, '0x')) {
101 $max = \intval($max, 16);
102 } elseif (0 === strpos($max, '0')) {
103 $max = \intval($max, 8);
104 } else {
105 $max = (int) $max;
106 }
107
108 switch (substr($memoryLimit, -1)) {
109 case 't': $max *= 1024;
110 // no break
111 case 'g': $max *= 1024;
112 // no break
113 case 'm': $max *= 1024;
114 // no break
115 case 'k': $max *= 1024;
116 }
117
118 return $max;
119 }
120 }
121