protected function _setup_metrics($data) { extract($this->params, EXTR_SKIP); $this->fn = XHProf_UI\Utils::safe_fn($fn); if (!empty($sort)) { if (array_key_exists($sort, $this->config->sortable_columns)) { $this->sort = $sort; } else { throw new Exception("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. if (!isset($data['main()']['wt'])) { if ($this->sort == 'wt') { $this->sort = '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; } // parent/child report doesn't support exclusive times yet. // So, change sort hyperlinks to closest fit. if (!empty($fn)) { $this->sort = str_replace('excl_', '', $this->sort); } $this->pc_stats = $this->stats = $this->display_calls ? array('fn', 'ct') : array('fn'); foreach ($this->config->possible_metrics as $metric => $desc) { if (isset($data['main()'][$metric])) { $this->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] . "%"; } } }
foreach ($ui->metrics as $metric) { ?> <td colspan="2" class="center"><?php echo number_format($ui->totals[0][$metric]) . ' ' . $ui->config->possible_metrics[$metric][1]; ?> </td> <td colspan="2" class="center">–</td> <?php } ?> </tr> <?php foreach ($data as $info) { ?> <tr><td class="fn"><a href="<?php echo $ui->url(array('fn' => XHProf_UI\Utils::safe_fn($info['fn']))); ?> "><?php echo $info['fn']; ?> </a></td><?php if ($ui->display_calls) { echo XHProf_UI\Utils::td_num($info['ct'], $ui->config->format_cbk['ct'], $ui->sort == 'ct'); echo XHProf_UI\Utils::td_pct($info['ct'], $ui->totals[0]['ct'], $ui->sort == 'ct'); } foreach ($ui->metrics as $metric) { // Inclusive metric echo XHProf_UI\Utils::td_num($info[$metric], $ui->config->format_cbk[$metric], $ui->sort == $metric); echo XHProf_UI\Utils::td_pct($info[$metric], $ui->totals[0][$metric], $ui->sort == $metric); // Exclusive Metric echo XHProf_UI\Utils::td_num($info['excl_' . $metric], $ui->config->format_cbk['excl_' . $metric], $ui->sort == 'excl_' . $metric);