Пример #1
0
 /**
  * @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] . "%";
         }
     }
 }