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

TimeDataCollector.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.68 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\HttpKernel\KernelInterface;
015  use Symfony\Component\HttpFoundation\Request;
016  use Symfony\Component\HttpFoundation\Response;
017   
018  /**
019   * TimeDataCollector.
020   *
021   * @author Fabien Potencier <fabien@symfony.com>
022   */
023  class TimeDataCollector extends DataCollector
024  {
025      protected $kernel;
026   
027      public function __construct(KernelInterface $kernel = null)
028      {
029          $this->kernel = $kernel;
030      }
031   
032      /**
033       * {@inheritdoc}
034       */
035      public function collect(Request $request, Response $response, \Exception $exception = null)
036      {
037          if (null !== $this->kernel) {
038              $startTime = $this->kernel->getStartTime();
039          } else {
040              $startTime = $request->server->get('REQUEST_TIME_FLOAT', $request->server->get('REQUEST_TIME'));
041          }
042   
043          $this->data = array(
044              'start_time' => $startTime * 1000,
045              'events'     => array(),
046          );
047      }
048   
049      /**
050       * Sets the request events.
051       *
052       * @param array $events The request events
053       */
054      public function setEvents(array $events)
055      {
056          foreach ($events as $event) {
057              $event->ensureStopped();
058          }
059   
060          $this->data['events'] = $events;
061      }
062   
063      /**
064       * Gets the request events.
065       *
066       * @return array The request events
067       */
068      public function getEvents()
069      {
070          return $this->data['events'];
071      }
072   
073      /**
074       * Gets the request elapsed time.
075       *
076       * @return float The elapsed time
077       */
078      public function getDuration()
079      {
080          if (!isset($this->data['events']['__section__'])) {
081              return 0;
082          }
083   
084          $lastEvent = $this->data['events']['__section__'];
085   
086          return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime();
087      }
088   
089      /**
090       * Gets the initialization time.
091       *
092       * This is the time spent until the beginning of the request handling.
093       *
094       * @return float The elapsed time
095       */
096      public function getInitTime()
097      {
098          if (!isset($this->data['events']['__section__'])) {
099              return 0;
100          }
101   
102          return $this->data['events']['__section__']->getOrigin() - $this->getStartTime();
103      }
104   
105      /**
106       * Gets the request time.
107       *
108       * @return int     The time
109       */
110      public function getStartTime()
111      {
112          return $this->data['start_time'];
113      }
114   
115      /**
116       * {@inheritdoc}
117       */
118      public function getName()
119      {
120          return 'time';
121      }
122  }
123