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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

BasePerformanceTest.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.90 KiB


001  <?php
002  /*
003   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
004   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
005   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
006   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
007   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
008   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
009   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
010   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
011   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
012   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
013   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
014   *
015   * This software consists of voluntary contributions made by many individuals
016   * and is licensed under the MIT license.
017   */
018   
019  namespace ProxyManagerTest\Functional;
020   
021  use PHPUnit_Framework_TestCase;
022   
023  /**
024   * Base performance test logic
025   *
026   * @author Marco Pivetta <ocramius@gmail.com>
027   * @license MIT
028   *
029   * @group Performance
030   * @coversNothing
031   */
032  abstract class BasePerformanceTest extends PHPUnit_Framework_TestCase
033  {
034      /**
035       * @var float time when last capture was started
036       */
037      private $startTime   = 0;
038   
039      /**
040       * @var int bytes when last capture was started
041       */
042      private $startMemory = 0;
043   
044      /**
045       * {@inheritDoc}
046       */
047      public static function setUpBeforeClass()
048      {
049          $header = "Performance test - " . get_called_class() . ":";
050   
051          echo "\n\n" . str_repeat('=', strlen($header)) . "\n" . $header . "\n\n";
052      }
053   
054      /**
055       * Start profiler snapshot
056       */
057      protected function startCapturing()
058      {
059          $this->startMemory = memory_get_usage();
060          $this->startTime   = microtime(true);
061      }
062   
063      /**
064       * Echo current profiler output
065       *
066       * @param string $messageTemplate
067       *
068       * @return array
069       */
070      protected function endCapturing($messageTemplate)
071      {
072          $time     = microtime(true) - $this->startTime;
073          $memory   = memory_get_usage() - $this->startMemory;
074   
075          if (gc_enable()) {
076              gc_collect_cycles();
077          }
078   
079          echo sprintf($messageTemplate, $time, $memory / 1024) . "\n";
080   
081          return array(
082              'time'   => $time,
083              'memory' => $memory
084          );
085      }
086   
087      /**
088       * Display comparison between two profiles
089       *
090       * @param array $baseProfile
091       * @param array $proxyProfile
092       */
093      protected function compareProfile(array $baseProfile, array $proxyProfile)
094      {
095          $baseMemory     = max(1, $baseProfile['memory']);
096          $timeOverhead   = (($proxyProfile['time'] / $baseProfile['time']) - 1) * 100;
097          $memoryOverhead = (($proxyProfile['memory'] / $baseMemory) - 1) * 100;
098   
099          echo sprintf('Comparison time / memory: %.2f%% / %.2f%%', $timeOverhead, $memoryOverhead) . "\n\n";
100      }
101  }
102