You are here

private function XHProfController::getRunRows in XHProf 8

Parameters

\Drupal\xhprof\XHProfLib\Run $run:

\Drupal\xhprof\XHProfLib\Report\ReportInterface $report:

int $length:

Return value

array

2 calls to XHProfController::getRunRows()
XHProfController::runAction in src/Controller/XHProfController.php
Renders the run.
XHProfController::symbolAction in src/Controller/XHProfController.php

File

src/Controller/XHProfController.php, line 278

Class

XHProfController
Displays profiling results.

Namespace

Drupal\xhprof\Controller

Code

private function getRunRows(Run $run, ReportInterface $report, $length, ReportInterface $globalReport = NULL, $symbol = NULL) {
  $rows = [];
  $runId = $run
    ->getId();
  $symbols = $report
    ->getSymbols($length);
  if ($symbol) {
    $globalSymbols = $globalReport
      ->getSymbols(-1);

    // Add the current function in the table.
    $this
      ->getCurrentFunctionRows($globalSymbols[$symbol], $rows);

    // Add parent functions in the table.
    $runSymbols = $run
      ->getSymbols();
    $parents = [];
    $children = [];
    foreach ($runSymbols as $value) {
      if ($value
        ->getChild() == $symbol && ($parent = $value
        ->getParent())) {
        $parents[$parent] = $globalSymbols[$parent];
      }
      elseif ($value
        ->getParent() == $symbol && ($child = $value
        ->getChild())) {
        $children[$child] = $value;
      }
    }
    $this
      ->getParentFunctionsRows($parents, $runId, $rows);
    if (\count($children)) {
      $columns = \current($symbols);
      $rows[] = [
        [
          'data' => new FormattableMarkup('<strong>@value</strong>', [
            '@value' => $this
              ->formatPlural(\count($children), 'Child function', 'Child functions (@count)'),
          ]),
          'colspan' => \count($columns),
        ],
      ];
    }
  }
  foreach ($symbols as $value) {

    // If its a symbol table, display only the children in the list.
    if (!$symbol || !empty($children[$value[0]])) {
      $text = $value[0];
      $url = Url::fromRoute('xhprof.symbol', [
        'run' => $runId,
        'symbol' => $value[0],
      ]);
      $value[0] = Link::fromTextAndUrl($text, $url)
        ->toString();
      $rows[] = $value;
    }
  }
  return $rows;
}