You are here

protected function BaseParser::computeFlatInfo in XHProf 8

Parameters

Symbol[] $symbols:

Return value

array

1 call to BaseParser::computeFlatInfo()
Parser::parse in src/XHProfLib/Parser/Parser.php

File

src/XHProfLib/Parser/BaseParser.php, line 172

Class

BaseParser
Class BaseReport

Namespace

Drupal\xhprof\XHProfLib\Parser

Code

protected function computeFlatInfo($symbols) {
  $metrics = $this
    ->getMetrics();

  // Compute inclusive times for each function.
  $symbol_tab = $this
    ->computeInclusiveTimes($symbols);

  // Total metric value is the metric value for "main()".
  foreach ($metrics as $metric) {
    $this->overall_totals[$metric] = $this->mainSymbol
      ->getMetric($metric);
  }

  // Initialize exclusive (self) metric value to inclusive metric value to start with.
  // In the same pass, also add up the total number of function calls.
  foreach ($symbol_tab as $symbol => $info) {
    foreach ($metrics as $metric) {
      $symbol_tab[$symbol]["excl_" . $metric] = $symbol_tab[$symbol][$metric];
    }

    // Keep track of total number of calls.
    $this->overall_totals["ct"] += $info["ct"];
  }

  // Adjust exclusive times by deducting inclusive time of children.
  foreach ($symbols as $symbol) {
    $parent = $symbol
      ->getParent();
    if ($parent) {
      foreach ($metrics as $metric) {

        // make sure the parent exists hasn't been pruned.
        if (isset($symbol_tab[$parent])) {
          $symbol_tab[$parent]["excl_" . $metric] -= $symbol
            ->getMetric($metric);
        }
      }
    }
  }
  return $symbol_tab;
}