You are here

class PerformanceTimingDataCollector in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/PerformanceTimingDataCollector.php \Drupal\webprofiler\DataCollector\PerformanceTimingDataCollector
  2. 8 webprofiler/src/DataCollector/PerformanceTimingDataCollector.php \Drupal\webprofiler\DataCollector\PerformanceTimingDataCollector
  3. 8.2 webprofiler/src/DataCollector/PerformanceTimingDataCollector.php \Drupal\webprofiler\DataCollector\PerformanceTimingDataCollector

Collects data about frontend performance.

Hierarchy

Expanded class hierarchy of PerformanceTimingDataCollector

1 string reference to 'PerformanceTimingDataCollector'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses PerformanceTimingDataCollector
webprofiler.performance_timing in webprofiler/webprofiler.services.yml
Drupal\webprofiler\DataCollector\PerformanceTimingDataCollector

File

webprofiler/src/DataCollector/PerformanceTimingDataCollector.php, line 15

Namespace

Drupal\webprofiler\DataCollector
View source
class PerformanceTimingDataCollector extends DataCollector implements DrupalDataCollectorInterface {
  use StringTranslationTrait, DrupalDataCollectorTrait;

  /**
   * {@inheritdoc}
   */
  public function collect(Request $request, Response $response, \Exception $exception = NULL) {
  }

  /**
   * @param $data
   */
  public function setData($data) {
    $this->data['performance'] = $data;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'performance_timing';
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this
      ->t('Performance Timing');
  }

  /**
   * {@inheritdoc}
   */
  public function getPanelSummary() {
    if (isset($this->data['performance'])) {
      $performanceData = new PerformanceTimingData($this->data['performance']);
      return $this
        ->t('TTFB: @ttfb', [
        '@ttfb' => sprintf('%.0f ms', $performanceData
          ->getTtfbTiming()),
      ]);
    }
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getIcon() {
    return 'iVBORw0KGgoAAAANSUhEUgAAABUAAAAcCAYAAACOGPReAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpi/P//PwO1ARMDDcCooUPEUEYi1AgAcQIQ+0P5H4B4IxAvwKaYmCSqAMT7gbgBajhMrB8qLkCsoQFQQ0CuOw/EBjgsLIAajmEouvdBhukD8UQgdkASwwXuA7EhNEhwuvQ8iXHSj2Q53FBY7BtADVxIoqEfoQYnYJPEF3bEROZ6WDDBvO+ALcCxJCsBAmpA4SuA7P2PBDQUEOGTDTA1TNCYs6dCRgIlxQswQ0GMB0A8nwgv4gqa+VCXgpMWC1QiEerF9WgaDmJJp/OhkUNIHUHQgJ4ecQHkiMKXXALQIowqpdR8pJi/AA0qvC4lFsyHYqK8zzhaRQ8NQwECDABNaU12xhTp2QAAAABJRU5ErkJggg==';
  }

  /**
   * {@inheritdoc}
   */
  public function getData() {
    $data = $this->data;
    if (isset($this->data['performance'])) {
      $performanceData = new PerformanceTimingData($this->data['performance']);
      $data['performance']['computed']['DNS lookup time'] = $performanceData
        ->getDNSTiming();
      $data['performance']['computed']['TCP handshake time'] = $performanceData
        ->getTCPTiming();
      $data['performance']['computed']['Time to first byte'] = $performanceData
        ->getTtfbTiming();
      $data['performance']['computed']['Data download time'] = $performanceData
        ->getDataTiming();
      $data['performance']['computed']['DOM building time'] = $performanceData
        ->getDomTiming();
    }
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalDataCollectorInterface::getDrupalSettings public function 1
DrupalDataCollectorInterface::getLibraries public function Returns the libraries needed in detail panel. 2
DrupalDataCollectorInterface::hasPanel public function Returns true if this datacollector has a detail panel. 2
PerformanceTimingDataCollector::collect public function
PerformanceTimingDataCollector::getData public function Overrides DrupalDataCollectorInterface::getData
PerformanceTimingDataCollector::getIcon public function Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface::getIcon
PerformanceTimingDataCollector::getName public function Returns the name of the collector. Overrides DrupalDataCollectorInterface::getName
PerformanceTimingDataCollector::getPanelSummary public function Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface::getPanelSummary
PerformanceTimingDataCollector::getTitle public function Returns the datacollector title. Overrides DrupalDataCollectorInterface::getTitle
PerformanceTimingDataCollector::setData public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.