You are here

class Run in XHProf 8

Provides value object for a profiler run.

Hierarchy

  • class \Drupal\xhprof\XHProfLib\Run

Expanded class hierarchy of Run

6 files declare their use of Run
BaseParser.php in src/XHProfLib/Parser/BaseParser.php
DiffParser.php in src/XHProfLib/Parser/DiffParser.php
FileStorage.php in src/XHProfLib/Storage/FileStorage.php
Parser.php in src/XHProfLib/Parser/Parser.php
ReportEngine.php in src/XHProfLib/Report/ReportEngine.php

... See full list

File

src/XHProfLib/Run.php, line 10

Namespace

Drupal\xhprof\XHProfLib
View source
class Run {

  /**
   * @var string
   */
  private $run_id;

  /**
   * @var string
   */
  private $namespace;

  /**
   * @var array
   */
  private $symbols = [];

  /**
   * @var \Drupal\xhprof\XHProfLib\Symbol\Symbol
   */
  private $mainSymbol;

  /**
   * @param string $run_id
   * @param string $namespace
   * @param array $data
   */
  public function __construct($run_id, $namespace, $data) {
    $this->run_id = $run_id;
    $this->namespace = $namespace;
    $this->symbols = $this
      ->parseSymbols($data);
  }

  /**
   * @return string
   */
  public function getId() {
    return $this->run_id;
  }

  /**+
   * @return array
   */
  public function getKeys() {
    return array_keys($this->symbols);
  }

  /**
   * @param string $key
   *
   * @return array
   */
  public function getMetrics($key) {
    return $this->symbols[$key];
  }

  /**
   * @return array
   */
  public function getSymbols() {
    return $this->symbols;
  }

  /**
   * @return Symbol
   */
  public function getMainSymbol() {
    return $this->mainSymbol;
  }

  /**
   * @return string
   */
  public function __toString() {
    return "Run id {$this->run_id}";
  }

  /**
   * @param array $data
   *
   * @return array
   */
  private function parseSymbols($data) {
    $symbols = [];
    foreach ($data as $parent_child => $metrics) {
      if (!isset($metrics['cpu'])) {
        $metrics['cpu'] = NULL;
      }
      if (!isset($metrics['mu'])) {
        $metrics['mu'] = NULL;
      }
      if (!isset($metrics['pmu'])) {
        $metrics['pmu'] = NULL;
      }
      $symbol = new Symbol($parent_child, $metrics['ct'], $metrics['wt'], $metrics['cpu'], $metrics['mu'], $metrics['pmu']);
      $symbols[$parent_child] = $symbol;
      if ($symbol
        ->getParent() == NULL) {
        $this->mainSymbol = $symbol;
      }
    }
    return $symbols;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Run::$mainSymbol private property
Run::$namespace private property
Run::$run_id private property
Run::$symbols private property
Run::getId public function
Run::getKeys public function
Run::getMainSymbol public function
Run::getMetrics public function
Run::getSymbols public function
Run::parseSymbols private function
Run::__construct public function
Run::__toString public function