/** * 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 = uprofiler_trim_run($run1_data, array($rep_symbol)); if ($diff_mode) { $run2_data = uprofiler_trim_run($run2_data, array($rep_symbol)); } } if ($diff_mode) { $run_delta = uprofiler_compute_diff($run1_data, $run2_data); $symbol_tab = uprofiler_compute_flat_info($run_delta, $totals); $symbol_tab1 = uprofiler_compute_flat_info($run1_data, $totals_1); $symbol_tab2 = uprofiler_compute_flat_info($run2_data, $totals_2); } else { $symbol_tab = uprofiler_compute_flat_info($run1_data, $totals); } $run1_txt = sprintf("<b>Run #%s:</b> %s", $run1, $run1_desc); $base_url_params = uprofiler_array_unset(uprofiler_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 = uprofiler_array_unset($base_url_params, 'run1'); $base_url_params = uprofiler_array_unset($base_url_params, 'run2'); $run1_link = uprofiler_render_link('View Run #' . $run1, "{$base_path}/?" . http_build_query(uprofiler_array_set($base_url_params, 'run', $run1))); $run2_txt = sprintf("<b>Run #%s:</b> %s", $run2, $run2_desc); $run2_link = uprofiler_render_link('View Run #' . $run2, "{$base_path}/?" . http_build_query(uprofiler_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[] = uprofiler_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[] = uprofiler_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 uprofiler_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 uprofiler 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 uprofiler_render_diff_image($uprofiler_runs_impl, $run1, $run2, $type, $threshold, $source) { $total1; $total2; $raw_data1 = $uprofiler_runs_impl->get_run($run1, $source, $desc_unused); $raw_data2 = $uprofiler_runs_impl->get_run($run2, $source, $desc_unused); // init_metrics($raw_data1, null, null); $children_table1 = uprofiler_get_children_table($raw_data1); $children_table2 = uprofiler_get_children_table($raw_data2); $symbol_tab1 = uprofiler_compute_flat_info($raw_data1, $total1); $symbol_tab2 = uprofiler_compute_flat_info($raw_data2, $total2); $run_delta = uprofiler_compute_diff($raw_data1, $raw_data2); $script = uprofiler_generate_dot_script($run_delta, $threshold, $source, null, null, true, $symbol_tab1, $symbol_tab2); $content = uprofiler_generate_image_by_dot($script, $type); uprofiler_generate_mime_header($type, strlen($content)); echo $content; }