コード例 #1
0
ファイル: BaseParser.php プロジェクト: shahinam/drupal8devel
 /**
  * @param $symbols
  *   All profiled symbols.
  * @param $symbol
  *   Set this to show the parent-child report.
  * @param $sort
  *   Metric used to sort.
  */
 protected function initMetrics($symbols, $symbol, $sort)
 {
     if (!empty($sort)) {
         if (array_key_exists($sort, ReportConstants::getSortableColumns())) {
             $this->sort_col = $sort;
         } else {
             print "Invalid Sort Key {$sort} specified in URL";
         }
     }
     // For C++ profiler runs, walltime attribute isn't present.
     // In that case, use "samples" as the default sort column.
     $wt = $this->mainSymbol->getWt();
     if (!isset($wt)) {
         if ($this->sort_col == "wt") {
             $this->sort_col = "samples";
         }
         // C++ profiler data doesn't have call counts.
         // ideally we should check to see if "ct" metric
         // is present for "main()". But currently "ct"
         // metric is artificially set to 1. So, relying
         // on absence of "wt" metric instead.
         $this->display_calls = FALSE;
     } else {
         $this->display_calls = TRUE;
     }
     // parent/child report doesn't support exclusive times yet.
     // So, change sort hyperlinks to closest fit.
     if (!empty($symbol)) {
         $this->sort_col = str_replace("excl_", "", $this->sort_col);
     }
     if ($this->display_calls) {
         $this->stats = array("fn", "ct", "Calls%");
     } else {
         $this->stats = array("fn");
     }
     $this->pc_stats = $this->stats;
     $possible_metrics = $this->getPossibleMetrics($symbols);
     foreach ($possible_metrics as $metric => $desc) {
         $mainMetric = $this->mainSymbol->getMetric($metric);
         if (isset($mainMetric)) {
             $metrics[] = $metric;
             // flat (top-level reports): we can compute
             // exclusive metrics reports as well.
             $this->stats[] = $metric;
             $this->stats[] = "I" . $desc[0] . "%";
             $this->stats[] = "excl_" . $metric;
             $this->stats[] = "E" . $desc[0] . "%";
             // parent/child report for a function: we can
             // only breakdown inclusive times correctly.
             $this->pc_stats[] = $metric;
             $this->pc_stats[] = "I" . $desc[0] . "%";
         }
     }
 }
コード例 #2
0
 /**
  * @param \Drupal\xhprof\XHProfLib\Run $run
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return string
  */
 public function runAction(Run $run, Request $request)
 {
     $length = $request->get('length', 100);
     $sort = $request->get('sort', 'wt');
     $report = $this->reportEngine->getReport(NULL, NULL, $run, NULL, NULL, $sort, NULL, NULL);
     $build['#title'] = $this->t('XHProf view report for %id', array('%id' => $run->getId()));
     $descriptions = ReportConstants::getDescriptions();
     $build['summary'] = array('title' => array('#type' => 'inline_template', '#template' => '<h3>Summary</h3>'), 'table' => array('#theme' => 'table', '#header' => array(), '#rows' => $this->getSummaryRows($report, $descriptions)));
     $build['length'] = array('#type' => 'inline_template', '#template' => $length == -1 ? '<h3>Displaying all functions, sorted by {{ sort }}.</h3>' : '<h3>Displaying top {{ length }} functions, sorted by {{ sort }}. [{{ all }}]</h3>', '#context' => array('length' => $length, 'all' => $this->l($this->t('show all'), new Url('xhprof.run', array('run' => $run->getId(), 'length' => -1))), 'sort' => Xss::filter($descriptions[$sort], array())));
     $build['table'] = array('#theme' => 'table', '#header' => $this->getRunHeader($report, $descriptions), '#rows' => $this->getRunRows($report, $length), '#attributes' => array('class' => array('responsive')), '#attached' => array('library' => array('xhprof/xhprof')));
     return $build;
 }
コード例 #3
0
ファイル: Report.php プロジェクト: shahinam/drupal8devel
 /**
  * @param $value
  * @param $metric
  * @param $totals
  *
  * @return mixed|string
  */
 private function getPercentValue($value, $metric, $totals)
 {
     if ($totals == 0) {
         $pct = "N/A%";
     } else {
         $format_cbk = ReportConstants::getFormatCbk();
         $pct = call_user_func($format_cbk[$metric . '_perc'], $value / abs($totals));
     }
     return $pct;
 }