You are here

public function Parser::parse in XHProf 8

Return value

array

Overrides ParserInterface::parse

File

src/XHProfLib/Parser/Parser.php, line 23

Class

Parser

Namespace

Drupal\xhprof\XHProfLib\Parser

Code

public function parse() {
  if (!empty($this->symbol)) {
    $symbols = $this
      ->trimRun($this->run
      ->getSymbols(), $this->symbol);
  }
  else {
    $symbols = $this->run
      ->getSymbols();
  }
  $data = $this
    ->computeFlatInfo($symbols);

  // @TODO Remove function name sorting.
  if ($this->sort === 'fn') {

    // Functions are array keys.
    \krsort($data);
  }
  else {
    $metric = $this->sort;
    \uasort($data, function ($a, $b) use ($metric) {

      // Arguments swapped to get more expensive values first.
      return $b[$metric] <=> $a[$metric];
    });
  }
  return $data;
}