Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

Profile.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 4.32 KiB


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