function get_summary($file_path, $probe = null) { $xhprof_data = XHProfRuns_Default::load_profile($file_path); $xhprof_data = xhprof_compute_flat_info($xhprof_data, $totals); $probe_count = 0; if ($probe != null && isset($xhprof_data[$probe])) { $probe_count = $xhprof_data[$probe]['ct']; } return array('pmu' => isset($totals['pmu']) ? $totals['pmu'] : '', 'mu' => isset($totals['mu']) ? $totals['mu'] : '', 'wt' => $totals['wt'], 'cpu' => $totals['cpu'], 'nbr' => $probe_count); }
public function render() { DarkConsoleXHProfPluginAPI::includeXHProfLib(); $data = $this->profileData; $GLOBALS['display_calls'] = true; $totals = array(); $flat = xhprof_compute_flat_info($data, $totals); unset($GLOBALS['display_calls']); $symbol = $this->symbol; $children = array(); $parents = array(); foreach ($this->profileData as $key => $counters) { if (strpos($key, '==>') !== false) { list($parent, $child) = explode('==>', $key, 2); } else { continue; } if ($parent == $symbol) { $children[$key] = $child; } else { if ($child == $symbol) { $parents[$key] = $parent; } } } $base_uri = $this->baseURI; $rows = array(); $rows[] = array('Metrics for this Call', '', '', ''); $rows[] = array(phutil_render_tag('a', array('href' => $base_uri . '?symbol=' . $symbol), phutil_escape_html($symbol)), $flat[$symbol]['ct'], $flat[$symbol]['wt'], '100%'); $rows[] = array('Parent Calls', '', '', ''); foreach ($parents as $key => $name) { $rows[] = array(phutil_render_tag('a', array('href' => $base_uri . '?symbol=' . $name), phutil_escape_html($name)), $data[$key]['ct'], $data[$key]['wt'], ''); } $rows[] = array('Child Calls', '', '', ''); $child_rows = array(); foreach ($children as $key => $name) { $child_rows[] = array($name, $data[$key]['ct'], $data[$key]['wt'], $data[$key]['wt'] / $flat[$symbol]['wt']); } $child_rows = isort($child_rows, 2); $child_rows = array_reverse($child_rows); $rows = array_merge($rows, $this->formatRows($child_rows)); $table = new AphrontTableView($rows); $table->setHeaders(array('Symbol', 'Count', 'Wall Time', '%')); $table->setColumnClasses(array('wide pri', 'n', 'n', 'n')); $panel = new AphrontPanelView(); $panel->setHeader('XHProf Profile'); $panel->appendChild($table); return $panel->render(); }
public function render() { DarkConsoleXHProfPluginAPI::includeXHProfLib(); $data = $this->profileData; $GLOBALS['display_calls'] = true; $totals = array(); $flat = xhprof_compute_flat_info($data, $totals); unset($GLOBALS['display_calls']); $symbol = $this->symbol; $children = array(); $parents = array(); foreach ($this->profileData as $key => $counters) { if (strpos($key, '==>') !== false) { list($parent, $child) = explode('==>', $key, 2); } else { continue; } if ($parent == $symbol) { $children[$key] = $child; } else { if ($child == $symbol) { $parents[$key] = $parent; } } } $rows = array(); $rows[] = array(pht('Metrics for this Call'), '', '', ''); $rows[] = $this->formatRow(array($symbol, $flat[$symbol]['ct'], $flat[$symbol]['wt'], 1.0)); $rows[] = array(pht('Parent Calls'), '', '', ''); foreach ($parents as $key => $name) { $rows[] = $this->formatRow(array($name, $data[$key]['ct'], $data[$key]['wt'], '')); } $rows[] = array(pht('Child Calls'), '', '', ''); $child_rows = array(); foreach ($children as $key => $name) { $child_rows[] = array($name, $data[$key]['ct'], $data[$key]['wt'], $data[$key]['wt'] / $flat[$symbol]['wt']); } $child_rows = isort($child_rows, 2); $child_rows = array_reverse($child_rows); $rows = array_merge($rows, array_map(array($this, 'formatRow'), $child_rows)); $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Symbol'), pht('Count'), pht('Wall Time'), '%')); $table->setColumnClasses(array('wide pri', 'n', 'n', 'n')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('XHProf Profile')); $panel->setTable($table); return $panel->render(); }
public function render() { DarkConsoleXHProfPluginAPI::includeXHProfLib(); $GLOBALS['display_calls'] = true; $totals = array(); $flat = xhprof_compute_flat_info($this->profileData, $totals); unset($GLOBALS['display_calls']); $aggregated = array(); foreach ($flat as $call => $counters) { $parts = explode('@', $call, 2); $agg_call = reset($parts); if (empty($aggregated[$agg_call])) { $aggregated[$agg_call] = $counters; } else { foreach ($aggregated[$agg_call] as $key => $val) { if ($key != 'wt') { $aggregated[$agg_call][$key] += $counters[$key]; } } } } $flat = $aggregated; $flat = isort($flat, 'wt'); $flat = array_reverse($flat); $rows = array(); $rows[] = array(pht('Total'), number_format($totals['ct']), number_format($totals['wt']) . ' us', '100.0%', number_format($totals['wt']) . ' us', '100.0%'); if ($this->limit) { $flat = array_slice($flat, 0, $this->limit); } foreach ($flat as $call => $counters) { $rows[] = array($this->renderSymbolLink($call), number_format($counters['ct']), number_format($counters['wt']) . ' us', sprintf('%.1f%%', 100 * $counters['wt'] / $totals['wt']), number_format($counters['excl_wt']) . ' us', sprintf('%.1f%%', 100 * $counters['excl_wt'] / $totals['wt'])); } Javelin::initBehavior('phabricator-tooltips'); $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Symbol'), pht('Count'), javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Total wall time spent in this function and all of ' . 'its children (children are other functions it called ' . 'while executing).'), 'size' => 200)), pht('Wall Time (Inclusive)')), '%', javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Wall time spent in this function, excluding time ' . 'spent in children (children are other functions it ' . 'called while executing).'), 'size' => 200)), pht('Wall Time (Exclusive)')), '%')); $table->setColumnClasses(array('wide pri', 'n', 'n', 'n', 'n', 'n')); $panel = new PHUIObjectBoxView(); $header = id(new PHUIHeaderView())->setHeader(pht('XHProf Profile')); if ($this->file) { $button = id(new PHUIButtonView())->setHref($this->file->getBestURI())->setText(pht('Download %s Profile', '.xhprof'))->setTag('a'); $header->addActionLink($button); } $panel->setHeader($header); $panel->appendChild($table); return $panel->render(); }
public function render() { DarkConsoleXHProfPluginAPI::includeXHProfLib(); $GLOBALS['display_calls'] = true; $totals = array(); $flat = xhprof_compute_flat_info($this->profileData, $totals); unset($GLOBALS['display_calls']); $aggregated = array(); foreach ($flat as $call => $counters) { $parts = explode('@', $call, 2); $agg_call = reset($parts); if (empty($aggregated[$agg_call])) { $aggregated[$agg_call] = $counters; } else { foreach ($aggregated[$agg_call] as $key => $val) { if ($key != 'wt') { $aggregated[$agg_call][$key] += $counters[$key]; } } } } $flat = $aggregated; $flat = isort($flat, 'wt'); $flat = array_reverse($flat); $rows = array(); $rows[] = array('Total', number_format($totals['ct']), number_format($totals['wt']) . ' us', '100.0%', number_format($totals['wt']) . ' us', '100.0%'); if ($this->limit) { $flat = array_slice($flat, 0, $this->limit); } $base_uri = $this->baseURI; foreach ($flat as $call => $counters) { $rows[] = array(phutil_render_tag('a', array('href' => $base_uri . '?symbol=' . $call), phutil_escape_html($call)), number_format($counters['ct']), number_format($counters['wt']) . ' us', sprintf('%.1f%%', 100 * $counters['wt'] / $totals['wt']), number_format($counters['excl_wt']) . ' us', sprintf('%.1f%%', 100 * $counters['excl_wt'] / $totals['wt'])); } $table = new AphrontTableView($rows); $table->setHeaders(array('Symbol', 'Count', 'Incl Wall Time', '%', 'Excl Wall Time', '%')); $table->setColumnClasses(array('wide pri', 'n', 'n', 'n', 'n', 'n')); $panel = new AphrontPanelView(); $panel->setHeader('XHProf Profile'); $panel->appendChild($table); return $panel->render(); }
function get_top_functions($profile, $metric_list, $how_many) { global $metric; $tots = null; $profile = XHProfRuns_Default::load_profile($profile); $profile = xhprof_compute_flat_info($profile, $tots); $result = array(); foreach ($metric_list as $metric => $blurb) { try { $metric_array = array_map("filter_metric", $profile); uasort($metric_array, 'compare'); $top_x = array_slice($metric_array, 0, $how_many); $metric_total = array_sum($metric_array); $metric_sub_total = array_sum($top_x); $top_x["*others*"] = $metric_total - $metric_sub_total; $result[$blurb] = array_map(null, array_keys($top_x), array_values($top_x)); } catch (Exception $e) { error_log("Processing metric {$m} failed"); } } return $result; }
public function run($method, $times = 1) { $runs = new XHProf\MemoryRuns(); $calls = array(); for ($i = 0; $i < $times; $i++) { $this->setUp(); xhprof_enable(XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU); $this->{$method}(); $data = xhprof_disable(); $runs->save_run($data, $method); $calls[] = $this->_callCount($data); $this->tearDown(); } $aggregated = $runs->aggregate(); $totals = array(); $result = xhprof_compute_flat_info($aggregated['raw'], $totals); $totals['ct'] = max($calls); // write aggregated run to disk $diskRuns = new \XHProfRuns_Default(); $runId = $diskRuns->save_run($aggregated['raw'], 'regreph'); return new TestResult($result, $totals, $runId); }
/** * Analyze raw data & generate the profiler report * (common for both single run mode and diff mode). * * @author: Kannan */ function profiler_report($url_params, $rep_symbol, $sort, $run1, $run1_desc, $run1_data, $run2 = 0, $run2_desc = "", $run2_data = array()) { global $totals; global $totals_1; global $totals_2; global $stats; global $pc_stats; global $diff_mode; global $base_path; // if we are reporting on a specific function, we can trim down // the report(s) to just stuff that is relevant to this function. // That way compute_flat_info()/compute_diff() etc. do not have // to needlessly work hard on churning irrelevant data. if (!empty($rep_symbol)) { $run1_data = xhprof_trim_run($run1_data, array($rep_symbol)); if ($diff_mode) { $run2_data = xhprof_trim_run($run2_data, array($rep_symbol)); } } if ($diff_mode) { $run_delta = xhprof_compute_diff($run1_data, $run2_data); $symbol_tab = xhprof_compute_flat_info($run_delta, $totals); $symbol_tab1 = xhprof_compute_flat_info($run1_data, $totals_1); $symbol_tab2 = xhprof_compute_flat_info($run2_data, $totals_2); } else { $symbol_tab = xhprof_compute_flat_info($run1_data, $totals); } $run1_txt = sprintf("<b>Run #%s:</b> %s", $run1, $run1_desc); $base_url_params = xhprof_array_unset(xhprof_array_unset($url_params, 'symbol'), 'all'); $top_link_query_string = "{$base_path}/index.php?" . http_build_query($base_url_params); if ($diff_mode) { $diff_text = "Diff"; $base_url_params = xhprof_array_unset($base_url_params, 'run1'); $base_url_params = xhprof_array_unset($base_url_params, 'run2'); $run1_link = xhprof_render_link('View Run #' . $run1, "{$base_path}/index.php?" . http_build_query(xhprof_array_set($base_url_params, 'run', $run1))); $run2_txt = sprintf("<b>Run #%s:</b> %s", $run2, $run2_desc); $run2_link = xhprof_render_link('View Run #' . $run2, "{$base_path}/index.php?" . http_build_query(xhprof_array_set($base_url_params, 'run', $run2))); } else { $diff_text = "Run"; } // set up the action links for operations that can be done on this report $links = array(); $links[] = xhprof_render_link("View Top Level {$diff_text} Report", $top_link_query_string); if ($diff_mode) { $inverted_params = $url_params; $inverted_params['run1'] = $url_params['run2']; $inverted_params['run2'] = $url_params['run1']; // view the different runs or invert the current diff $links[] = $run1_link; $links[] = $run2_link; $links[] = xhprof_render_link('Invert ' . $diff_text . ' Report', "{$base_path}/index.php?" . http_build_query($inverted_params)); } // lookup function typeahead form $links[] = '<input class="function_typeahead" ' . ' type="input" size="40" maxlength="100" />'; echo xhprof_render_actions($links); echo '<dl class=phprof_report_info>' . ' <dt>' . $diff_text . ' Report</dt>' . ' <dd>' . ($diff_mode ? $run1_txt . '<br><b>vs.</b><br>' . $run2_txt : $run1_txt) . ' </dd>' . ' <dt>Tip</dt>' . ' <dd>Click a function name below to drill down.</dd>' . '</dl>' . '<div style="clear: both; margin: 3em 0em;"></div>'; // data tables if (!empty($rep_symbol)) { if (!isset($symbol_tab[$rep_symbol])) { echo "<hr>Symbol <b>{$rep_symbol}</b> not found in XHProf run</b><hr>"; return; } /* single function report with parent/child information */ if ($diff_mode) { $info1 = isset($symbol_tab1[$rep_symbol]) ? $symbol_tab1[$rep_symbol] : null; $info2 = isset($symbol_tab2[$rep_symbol]) ? $symbol_tab2[$rep_symbol] : null; symbol_report($url_params, $run_delta, $symbol_tab[$rep_symbol], $sort, $rep_symbol, $run1, $info1, $run2, $info2); } else { symbol_report($url_params, $run1_data, $symbol_tab[$rep_symbol], $sort, $rep_symbol, $run1); } } else { /* flat top-level report of all functions */ full_report($url_params, $symbol_tab, $sort, $run1, $run2); } }
function xhprof_render_diff_image($xhprof_runs_impl, $run1, $run2, $type, $threshold, $source) { $total1; $total2; $raw_data1 = $xhprof_runs_impl->get_run($run1, $source, $desc_unused); $raw_data2 = $xhprof_runs_impl->get_run($run2, $source, $desc_unused); // init_metrics($raw_data1, null, null); $children_table1 = xhprof_get_children_table($raw_data1); $children_table2 = xhprof_get_children_table($raw_data2); $symbol_tab1 = xhprof_compute_flat_info($raw_data1, $total1); $symbol_tab2 = xhprof_compute_flat_info($raw_data2, $total2); $run_delta = xhprof_compute_diff($raw_data1, $raw_data2); $script = xhprof_generate_dot_script($run_delta, $threshold, $source, null, null, true, $symbol_tab1, $symbol_tab2); $content = xhprof_generate_image_by_dot($script, $type); xhprof_generate_mime_header($type, strlen($content)); echo $content; }
function slow_page($dir_path, $profile_name, $max_time, &$flat_profile) { // XXX: xhprof depends on this global for doing entry counts global $display_calls; $display_calls = true; $profile = XHProfRuns_Default::load_profile("{$dir_path}/{$profile_name}"); $dummy = null; $flat_profile = xhprof_compute_flat_info($profile, $dummy); return $flat_profile["main()"]["wt"]; }
function extract_functions($files, $game_name, $run_id, $aggregate_dir) { // XXX: xhprof depends on this global for doing entry counts global $display_calls; $display_calls = true; $functions_to_extract = array("MC::set", "MC::get", "ApcManager::get", "ApcManager::set", "serialize", "unserialize", "AMFBaseSerializer::serialize", "AMFBaseDeserializer::deserialize"); if ($game_cfg = load_game_config($game_name)) { //$game_cfg = $game_cfg[$game_name]; if (isset($game_cfg["tracked_functions"])) { $functions_to_extract = $game_cfg["tracked_functions"]; } } $prof_obj = new XHProfRuns_Default(); $runs = xhprof_aggregate_runs_list($prof_obj, $files); if ($runs['raw']) { $aggregate = $runs['raw']; } else { return; } # keep this in sync with the aggregate_files # $aggregate_file_name = "{$run_id}.xhprof"; $overall_totals = null; $flattened_profile = xhprof_compute_flat_info($aggregate, $overall_totals); $interesting_funcs = extract_interesting_functions($flattened_profile, $functions_to_extract); $top_funcs = get_top_functions($flattened_profile, 5); $xhprof = array("interesting" => $interesting_funcs, "top functions" => $top_funcs, "files" => $files); file_put_contents("{$aggregate_dir}/{$run_id}.extract", serialize($xhprof)); }
<?php $run1 = $_SERVER['argv'][1]; $run2 = $_SERVER['argv'][2]; $extra = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : ''; $source = isset($_SERVER['argv'][4]) ? $_SERVER['argv'][4] : 'drupal-perf'; include_once dirname(__FILE__) . '/xhprof/xhprof_lib/utils/xhprof_lib.php'; include_once dirname(__FILE__) . '/xhprof/xhprof_lib/utils/xhprof_runs.php'; include_once dirname(__FILE__) . '/xhprof/xhprof_lib/display/xhprof.php'; $xhprof_runs_impl = new XHProfRuns_Default(); $run1_data = $xhprof_runs_impl->get_run($run1, $source, $description1); $run2_data = $xhprof_runs_impl->get_run($run2, $source, $description2); $run_delta = xhprof_compute_diff($run1_data, $run2_data); $symbol_tab = xhprof_compute_flat_info($run_delta, $totals); $symbol_tab1 = xhprof_compute_flat_info($run1_data, $totals_1); $symbol_tab2 = xhprof_compute_flat_info($run2_data, $totals_2); $metrics = xhprof_get_metrics($run_delta); function print_pct($numer, $denom) { if ($denom == 0) { $pct = "N/A%"; } else { $pct = xhprof_percent_format($numer / abs($denom)); } return $pct; } function print_num($num, $fmt_func = null) { if (!empty($fmt_func)) { $num = call_user_func($fmt_func, $num); }
public static function render($runData, $params, $xhprofData, $symbol) { global $totals; init_metrics($xhprofData, $symbol); // if we are reporting on a specific function, we can trim down // the report(s) to just stuff that is relevant to this function. // That way compute_flat_info()/compute_diff() etc. do not have // to needlessly work hard on churning irrelevant data. if (!empty($symbol)) { $xhprofData = xhprof_trim_run($xhprofData, array($symbol)); } $symbol_tab = xhprof_compute_flat_info($xhprofData, $totals); ?> <!DOCTYPE HTML><html> <?php HtmlHead::render($runData['namespace'] . ' - SugarCRM XHProf Viewer', array('xhprof/css/xhprof.css', 'bower_components/bootstrap/dist/css/bootstrap.min.css', 'bower_components/font-awesome/css/font-awesome.min.css', 'xhprof/css/run-page.css'), array('bower_components/jquery/dist/jquery.min.js', 'bower_components/bootstrap/dist/js/bootstrap.min.js', 'xhprof/js/symbol-typeahead.js')); ?> <body class="container-fluid"> <div> <div class="page-header form-inline" style="margin-top: 20px;"> <div class="navbar-form pull-right" style="padding-right:0;"> <a class="btn btn-default btn-overall-summary"> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <div><?php static::renderOverallSummary(); ?> </div> </a> <a class="btn btn-primary" href="<?php echo $params['list_url']; ?> "> <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> Back To List </a> </div> <h1><p>SugarCRM XHProf Viewer </p><small><?php echo htmlentities($runData['namespace']); ?> </small></h1> </div> </div> <?php if (!$symbol) { TopTabsTemplate::render($runData); } ?> <?php profiler_report($params, $symbol, $xhprofData, $symbol_tab); ?> <script type="text/javascript"> window.TYPEAHEAD_URL = '<?php echo static::typeAheadUrl(); ?> '; window.SYMBOL_URL = '<?php echo CurrentPageHelper::url(); ?> '; $(function () { $('[data-toggle="tooltip"]').tooltip({html: true}) }); </script> </body> </html> <?php }
/** * Analyze raw data & generate the profiler report * (common for both single run mode and diff mode). * * @author: Kannan */ function profiler_report($url_params, $rep_symbol, $sort, $run1, $run1_desc, $run1_data, $run2 = 0, $run2_desc = "", $run2_data = array()) { global $totals; global $totals_1; global $totals_2; global $stats; global $pc_stats; global $diff_mode; global $base_path; // if we are reporting on a specific function, we can trim down // the report(s) to just stuff that is relevant to this function. // That way compute_flat_info()/compute_diff() etc. do not have // to needlessly work hard on churning irrelevant data. if (!empty($rep_symbol)) { $run1_data = xhprof_trim_run($run1_data, array($rep_symbol)); if ($diff_mode) { $run2_data = xhprof_trim_run($run2_data, array($rep_symbol)); } } if ($diff_mode) { $run_delta = xhprof_compute_diff($run1_data, $run2_data); $symbol_tab = xhprof_compute_flat_info($run_delta, $totals); $symbol_tab1 = xhprof_compute_flat_info($run1_data, $totals_1); $symbol_tab2 = xhprof_compute_flat_info($run2_data, $totals_2); } else { $symbol_tab = xhprof_compute_flat_info($run1_data, $totals); } $run1_txt = sprintf("<b>Run #%s:</b> %s", $run1, $run1_desc); $base_url_params = xhprof_array_unset(xhprof_array_unset($url_params, 'symbol'), 'all'); $top_link_query_string = "{$base_path}/?" . http_build_query($base_url_params); if ($diff_mode) { $diff_text = "Diff"; $base_url_params = xhprof_array_unset($base_url_params, 'run1'); $base_url_params = xhprof_array_unset($base_url_params, 'run2'); $run1_link = xhprof_render_link('View Run #' . $run1, "{$base_path}/?" . http_build_query(xhprof_array_set($base_url_params, 'run', $run1))); $run2_txt = sprintf("<b>Run #%s:</b> %s", $run2, $run2_desc); $run2_link = xhprof_render_link('View Run #' . $run2, "{$base_path}/?" . http_build_query(xhprof_array_set($base_url_params, 'run', $run2))); } else { $diff_text = "Run"; } // set up the action links for operations that can be done on this report $links = array(); // $links []= xhprof_render_link("View Top Level $diff_text Report", // $top_link_query_string); if ($diff_mode) { $inverted_params = $url_params; $inverted_params['run1'] = $url_params['run2']; $inverted_params['run2'] = $url_params['run1']; // view the different runs or invert the current diff $links[] = $run1_link; $links[] = $run2_link; $links[] = xhprof_render_link('Invert ' . $diff_text . ' Report', "{$base_path}/?" . http_build_query($inverted_params)); } // lookup function typeahead form // $links [] = '<input class="function_typeahead" ' . // ' type="input" size="40" maxlength="100" />'; // echo xhprof_render_actions($links); // data tables if (!empty($rep_symbol)) { if (!isset($symbol_tab[$rep_symbol])) { echo "<hr>Symbol <b>{$rep_symbol}</b> not found in XHProf run</b><hr>"; echo "<div id='fn_not_found'></div>"; return; } /* single function report with parent/child information */ if ($diff_mode) { $info1 = isset($symbol_tab1[$rep_symbol]) ? $symbol_tab1[$rep_symbol] : null; $info2 = isset($symbol_tab2[$rep_symbol]) ? $symbol_tab2[$rep_symbol] : null; //Need to print the header table ,return in the diff profile symbol_report($url_params, $run_delta, $symbol_tab[$rep_symbol], $sort, $rep_symbol, $run1, $info1, $run2, $info2); } else { echo '<div style="float:right"><button id="back_button" style="float:right;width:100px;" type=button >Back</button>'; echo '<button id="home_button" style="float:right;width:100px;" type=button >Home</button></div>'; echo "<div id='fn_info' style='text-align:center;font-size:20px;font-weight:bold;'> Parent/Child Function for " . $url_params['symbol'] . "</div>"; print '<br/ ><br /><div style="float:left;">'; print '<table style="margin:20px;"><tr><td valign="top">'; print '<table id="icfn-summary" class="summary" style="border-color:grey;font-size:16px; border:1px solid ;border-color:grey">' . "\n"; print "<tr><td colspan=2 style='background: #D8D8DA url(http://yui.yahooapis.com/2.9.0/build/assets/skins/sam/sprite.png) repeat-x 0 0;text-align:center'>Page Summary</td></tr>"; $file_arr = explode("/", $url_params['file']); $game_id = $file_arr[count($file_arr) - 3]; $game_me = explode("_", $game_id); $game = $game_me[0]; if ($run1 == "" && realpath($url_params['file']) == $url_params['file']) { $file_arr1 = explode("/", realpath($url_params['file'])); $temp = $file_arr1[count($file_arr1) - 1]; $temp_arr = explode(":", $temp); $run1 = $temp_arr[1] . "." . $temp_arr[3]; } if (sizeof($game_me) > 1) { if (is_numeric($game_me[sizeof($game_me) - 1])) { for ($i = 1; $i < sizeof($game_me) - 1; $i++) { $game = $game . "_" . $game_me[$i]; } $array = $game_me[sizeof($game_me) - 1]; } else { for ($i = 1; $i < sizeof($game_me); $i++) { $game = $game . "_" . $game_me[$i]; } $array = "all"; } } else { $array = "all"; } if ($file_arr[1] == 'db') { $game_me = explode("_", $file_arr[3]); $game = $game_me[0]; if (sizeof($game_me) > 1) { if (is_numeric($game_me[sizeof($game_me) - 1])) { for ($i = 1; $i < sizeof($game_me) - 1; $i++) { $game = $game . "_" . $game_me[$i]; } $array = $game_me[sizeof($game_me) - 1]; } else { for ($i = 1; $i < sizeof($game_me); $i++) { $game = $game . "_" . $game_me[$i]; } $array = "all"; } } } echo "<tr><td>Game:</td><td>" . $game . "</td></tr>"; echo "<tr><td>Array:</td><td>" . $array . "</td></tr>"; echo "<tr><td>Page:</td><td>" . substr($run1, 11) . "</td></tr>"; echo "<tr><td>Release Tag:</td><td>"; $game_id = $file_arr[count($file_arr) - 3]; $game_me = explode("_", $game_id); $_GET['game'] = $game; $_GET['timestamp'] = intval($run1 . substr(0, 10)); include_once "get_latest_release.php"; echo "</td></tr>"; $timestamp = intval($run1 . substr(0, 10)); echo "<tr><td>Time:</td><td id='time'>{$timestamp}</td></tr>"; print "</table>"; print '</td>'; print '<td valign="top">'; print '<table id="fn-summary" class="summary" style="border-color:grey;font-size:16px; border:1px solid ;border-color:grey">' . "\n"; print "<tr><td colspan=2 style='background: #D8D8DA url(http://yui.yahooapis.com/2.9.0/build/assets/skins/sam/sprite.png) repeat-x 0 0;text-align:center'>Function Summary</td></tr>"; print '</table>'; print '</td></tr></table>'; print "<div>"; echo '<button id="callgraph_button_fn" style="margin-left:30px; width:125px;" type=button onClick="changeUrlfn(\'callgraph.php\')">Call Graph</button>'; echo "<div id='function_table' ></div>"; return; symbol_report($url_params, $run1_data, $symbol_tab[$rep_symbol], $sort, $rep_symbol, $run1); } } else { /* flat top-level report of all functions */ full_report($url_params, $symbol_tab, $sort, $run1, $run2); } }
/** * profiled data * * @return array */ function _getProfData($xhprof_data) { if (!$xhprof_data) { return array('to' => null, 'sum' => null); } global $display_calls; // must require for xhprof library $display_calls = true; $totals = array(); $symbol_tab = xhprof_compute_flat_info($xhprof_data, $totals); $flat_data = array(); foreach ($symbol_tab as $symbol => $info) { $tmp = $info; $tmp["fn"] = $symbol; $flat_data[] = $tmp; } usort($flat_data, 'XhprofPanel::sort_by'); $to = $flat_data; foreach ($flat_data as $name => $inf) { foreach ($totals as $k => $v) { if (!array_key_exists($k, $inf)) { continue; } if ($inf[$k] > 0) { if (isset($totals[$k]) and $totals[$k] > 0) { $to[$name]['p_' . $k] = round($inf[$k] / $totals[$k] * 100, 1) . '%'; } } else { $to[$name]['p_' . $k] = '0%'; } } } return array('symbol_table' => $to, 'totals' => $totals); }