Esempio n. 1
0
    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 
    }
Esempio n. 2
0
/**
 * 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);
    }
}
Esempio n. 3
0
/**
 * 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);
    }
}