You are here

public function XHProfParser::getMetrics in XHProf 7

Same name and namespace in other branches
  1. 6 XHProfLib/XHProfParser.php \XHProfParser::getMetrics()

File

XHProfLib/XHProfParser.php, line 33

Class

XHProfParser

Code

public function getMetrics($symbol) {
  if (!isset($this->symbol_totals[$symbol])) {
    $this->symbol_totals[$symbol] = array(
      'ct' => 0,
      'wt' => 0,
      'cpu' => 0,
      'mu' => 0,
      'pmu' => 0,
    );
  }
  foreach ($this->data as $key => $symbol_data) {
    if ($key !== 'main()') {
      list($caller, $cur_symbol) = explode('==>', $key);
      if ($cur_symbol == $symbol) {
        foreach ($symbol_data as $metric => $value) {
          $this->symbol_totals[$symbol][$metric] += $value;
        }
        $this->symbol_totals[$symbol] = $this
          ->calculatePercentages($this->symbol_totals[$symbol]);
        $this->symbol_totals[$symbol] = $this->symbol_totals[$symbol];
        return $this->symbol_totals[$symbol];
      }
    }
  }
}