public static function render($run_data, $symbol_info, $rep_symbol) { global $metrics; HeaderTemplate::prepareColumns($symbol_info, true); $columnsCount = HeaderTemplate::getColumnsCount(); ?> <div class="panel panel-default panel-functions"> <div class="panel-heading form-inline"> <h3 class="panel-title" style="display: inline-block;">Parent/Child report for <strong><?php ShortenNameHelper::render($rep_symbol, 45); ?> </strong> </h3> <?php SymbolSearchInputTemplate::render(); ?> <a class="btn btn-primary btn-sm" target="_blank" href="<?php echo static::callgraphUrl($rep_symbol); ?> "> <i class="fa fa-pie-chart"></i> View Callgraph </a> </div> <table class="table table-functions table-condensed table-bordered"> <?php HeaderTemplate::render(); ?> <tr class="no-hover"> <td><b><i><center>Current Function</center></i></b></td> <td colspan="<?php echo $columnsCount; ?> "></td> </tr> <?php print_function_info($symbol_info); ?> <tr> <?php $exclColumns = HeaderTemplate::getExclColumns(); foreach (HeaderTemplate::getColumns() as $column => $meta) { ?> <?php if ($column == 'fn') { ?> <td style='text-align:right;'>Exclusive Metrics for Current Function</td> <?php } elseif (isset($exclColumns['excl_' . $column])) { ?> <?php print_column_info($symbol_info, 'excl_' . $column, $exclColumns['excl_' . $column]); ?> <?php } else { ?> <td></td> <?php if (!empty($meta['percentage'])) { ?> <td></td> <?php } ?> <?php } ?> <?php } ?> </tr> <?php // list of callers/parent functions $results = array(); // $base_ct = $symbol_info["ct"]; $base_info = array(); foreach ($metrics as $metric) { $base_info[$metric] = $symbol_info[$metric]; } foreach ($run_data as $parent_child => $info) { list($parent, $child) = xhprof_parse_parent_child($parent_child); if ($child == $rep_symbol && $parent) { $info_tmp = $info; $info_tmp["fn"] = $parent; $results[] = $info_tmp; } } usort($results, 'sort_cbk'); if (count($results) > 0) { $title = 'Parent functions'; if (count($results) > 1) { $title .= 's'; } print "<tr class=\"no-hover\"><td>"; print "<b><i><center>" . $title . "</center></i></b>"; print "</td><td colspan='{$columnsCount}'></td></tr>"; foreach ($results as $info) { print_function_info($info); } } // list of callees/child functions $results = array(); $base_ct = 0; foreach ($run_data as $parent_child => $info) { list($parent, $child) = xhprof_parse_parent_child($parent_child); if ($parent == $rep_symbol) { $info_tmp = $info; $info_tmp["fn"] = $child; $results[] = $info_tmp; $base_ct += $info["ct"]; } } usort($results, 'sort_cbk'); if (count($results)) { $title = 'Child function'; if (count($results) > 1) { $title .= 's'; } print "<tr class=\"no-hover\"><td>"; print "<b><i><center>" . $title . "</center></i></b>"; print "</td><td colspan='{$columnsCount}'></td></tr>"; foreach ($results as $info) { print_function_info($info); } } ?> </table> </div> <?php }
/** * Print non-hierarchical (flat-view) of profiler data. * * @author Kannan */ function print_flat_data($url_params, $title, $flat_data, $sort, $run1, $run2, $limit) { global $stats; global $sortable_columns; global $vwbar; global $base_path; $size = count($flat_data); if (!$limit) { // no limit $limit = $size; $display_link = ""; } else { $display_link = xhprof_render_link(" [ <b class=bubble>display all </b>]", "{$base_path}/index.php?" . http_build_query(xhprof_array_set($url_params, 'all', 1))); } print "<h3 align=center>{$title} {$display_link}</h3><br>"; print '<table border=1 cellpadding=2 cellspacing=1 width="90%" ' . 'rules=rows bordercolor="#bdc7d8" align=center>'; print '<tr bgcolor="#bdc7d8" align=right>'; foreach ($stats as $stat) { $desc = stat_description($stat); if (array_key_exists($stat, $sortable_columns)) { $href = "{$base_path}/index.php?" . http_build_query(xhprof_array_set($url_params, 'sort', $stat)); $header = xhprof_render_link($desc, $href); } else { $header = $desc; } if ($stat == "fn") { print "<th align=left><nobr>{$header}</th>"; } else { print "<th " . $vwbar . "><nobr>{$header}</th>"; } } print "</tr>\n"; if ($limit >= 0) { $limit = min($size, $limit); for ($i = 0; $i < $limit; $i++) { print_function_info($url_params, $flat_data[$i], $sort, $run1, $run2); } } else { // if $limit is negative, print abs($limit) items starting from the end $limit = min($size, abs($limit)); for ($i = 0; $i < $limit; $i++) { print_function_info($url_params, $flat_data[$size - $i - 1], $sort, $run1, $run2); } } print "</table>"; // let's print the display all link at the bottom as well... if ($display_link) { echo '<div style="text-align: left; padding: 2em">' . $display_link . '</div>'; } }
/** * Print non-hierarchical (flat-view) of profiler data. * * @author Kannan */ function print_flat_data($title, $flat_data, $limit, $callGraphButton) { $size = count($flat_data); if (!$limit) { $limit = $size; $display_link = ""; } else { $display_link = "<a href='" . CurrentPageHelper::url(array('all' => 1)) . "' class='btn btn-sm btn-primary'>Display All</a>"; } print '<div class="panel panel-default panel-functions">'; print "<div class=\"panel-heading form-inline \"><h3 class=\"panel-title\" style='display:inline-block;'>{$title}</h3> "; SymbolSearchInputTemplate::render(); echo "{$display_link} {$callGraphButton}"; print "</div>"; print '<table class="table table-functions table-condensed table-bordered">'; \Sugarcrm\XHProf\Viewer\Templates\Run\SymbolsTable\HeaderTemplate::prepareColumns(reset($flat_data)); \Sugarcrm\XHProf\Viewer\Templates\Run\SymbolsTable\HeaderTemplate::render(); if ($limit >= 0) { $limit = min($size, $limit); for ($i = 0; $i < $limit; $i++) { print_function_info($flat_data[$i]); } } else { // if $limit is negative, print abs($limit) items starting from the end $limit = min($size, abs($limit)); for ($i = 0; $i < $limit; $i++) { print_function_info($flat_data[$size - $i - 1]); } } print "</table>"; // let's print the display all link at the bottom as well... if ($display_link) { echo '<div class="panel-footer">' . $display_link . '</div>'; } print '</div>'; }