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] . "%"; } } }
</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); echo XHProf_UI\Utils::td_pct($info['excl_' . $metric], $ui->totals[0][$metric], $ui->sort == 'excl_' . $metric); } ?> </tr> <?php } ?> </tbody> </table>
* determines a profiler run. * * @param string $run run id, or comma separated sequence of * run ids. The latter is used if an aggregate * report of the runs is desired. * * @param string $wts Comma separate list of integers. * Represents the weighted ratio in * which which a set of runs will be * aggregated. [Used only for aggregate * reports.] * * @param string $symbol Function symbol. If non-empty then the * parent/child view of this function is * displayed. If empty, a flat-profile view * of the functions is displayed. * * @param string $run1 Base run id (for diff reports) * * @param string $run2 New run id (for diff reports) * */ $xhprof_config = new XHProf_UI\Config(); $xhprof_ui = new XHProf_UI(array('run' => array(XHProf_UI\Utils::STRING_PARAM, ''), 'compare' => array(XHProf_UI\Utils::STRING_PARAM, ''), 'wts' => array(XHProf_UI\Utils::STRING_PARAM, ''), 'fn' => array(XHProf_UI\Utils::STRING_PARAM, ''), 'sort' => array(XHProf_UI\Utils::STRING_PARAM, 'wt'), 'run1' => array(XHProf_UI\Utils::STRING_PARAM, ''), 'run2' => array(XHProf_UI\Utils::STRING_PARAM, ''), 'namespace' => array(XHProf_UI\Utils::STRING_PARAM, 'xhprof'), 'all' => array(XHProf_UI\Utils::UINT_PARAM, 0)), $xhprof_config); if (!($xhprof_report = $xhprof_ui->generate_report())) { echo "No XHProf runs specified in the URL."; XHProf_UI\Utils::list_runs($xhprof_ui->dir); } $xhprof_report->render(); } include XHPROF_ROOT . '/views/footer.php';
?> </th></tr> <?php foreach ($results[$pc] as $info) { ?> <tr><td><a href="<?php echo $ui->url(array('fn' => $info['fn'])); ?> "><?php echo htmlentities($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'], $base_ct[$pc], $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], $pc == 'parent' ? $ui->totals[$metric] : $base_info[$metric], $ui->sort == $metric); } ?> </tr> <?php } } } ?> </tbody> </table>