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 |
Profile.php
001 <?php
002
003 /*
004 * This file is part of Twig.
005 *
006 * (c) 2015 Fabien Potencier
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 /**
013 * @author Fabien Potencier <fabien@symfony.com>
014 */
015 class Twig_Profiler_Profile implements IteratorAggregate, Serializable
016 {
017 const ROOT = 'ROOT';
018 const BLOCK = 'block';
019 const TEMPLATE = 'template';
020 const MACRO = 'macro';
021
022 private $template;
023 private $name;
024 private $type;
025 private $starts = array();
026 private $ends = array();
027 private $profiles = array();
028
029 public function __construct($template = 'main', $type = self::ROOT, $name = 'main')
030 {
031 $this->template = $template;
032 $this->type = $type;
033 $this->name = 0 === strpos($name, '__internal_') ? 'INTERNAL' : $name;
034 $this->enter();
035 }
036
037 public function getTemplate()
038 {
039 return $this->template;
040 }
041
042 public function getType()
043 {
044 return $this->type;
045 }
046
047 public function getName()
048 {
049 return $this->name;
050 }
051
052 public function isRoot()
053 {
054 return self::ROOT === $this->type;
055 }
056
057 public function isTemplate()
058 {
059 return self::TEMPLATE === $this->type;
060 }
061
062 public function isBlock()
063 {
064 return self::BLOCK === $this->type;
065 }
066
067 public function isMacro()
068 {
069 return self::MACRO === $this->type;
070 }
071
072 public function getProfiles()
073 {
074 return $this->profiles;
075 }
076
077 public function addProfile(Twig_Profiler_Profile $profile)
078 {
079 $this->profiles[] = $profile;
080 }
081
082 /**
083 * Returns the duration in microseconds.
084 *
085 * @return int
086 */
087 public function getDuration()
088 {
089 if ($this->isRoot() && $this->profiles) {
090 // for the root node with children, duration is the sum of all child durations
091 $duration = 0;
092 foreach ($this->profiles as $profile) {
093 $duration += $profile->getDuration();
094 }
095
096 return $duration;
097 }
098
099 return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
100 }
101
102 /**
103 * Returns the memory usage in bytes.
104 *
105 * @return int
106 */
107 public function getMemoryUsage()
108 {
109 return isset($this->ends['mu']) && isset($this->starts['mu']) ? $this->ends['mu'] - $this->starts['mu'] : 0;
110 }
111
112 /**
113 * Returns the peak memory usage in bytes.
114 *
115 * @return int
116 */
117 public function getPeakMemoryUsage()
118 {
119 return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0;
120 }
121
122 /**
123 * Starts the profiling.
124 */
125 public function enter()
126 {
127 $this->starts = array(
128 'wt' => microtime(true),
129 'mu' => memory_get_usage(),
130 'pmu' => memory_get_peak_usage(),
131 );
132 }
133
134 /**
135 * Stops the profiling.
136 */
137 public function leave()
138 {
139 $this->ends = array(
140 'wt' => microtime(true),
141 'mu' => memory_get_usage(),
142 'pmu' => memory_get_peak_usage(),
143 );
144 }
145
146 public function getIterator()
147 {
148 return new ArrayIterator($this->profiles);
149 }
150
151 public function serialize()
152 {
153 return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles));
154 }
155
156 public function unserialize($data)
157 {
158 list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data);
159 }
160 }
161