当前位置: 首页>>代码示例>>PHP>>正文


PHP xhprof_compute_diff函数代码示例

本文整理汇总了PHP中xhprof_compute_diff函数的典型用法代码示例。如果您正苦于以下问题:PHP xhprof_compute_diff函数的具体用法?PHP xhprof_compute_diff怎么用?PHP xhprof_compute_diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xhprof_compute_diff函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: profiler_report

/**
 * 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);
    }
}
开发者ID:bdlangton,项目名称:xhprof-1,代码行数:81,代码来源:xhprof.php

示例2: isset

<?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);
    }
开发者ID:ajsalminen,项目名称:xhprof-kit,代码行数:31,代码来源:xhprof-check.php

示例3: xhprof_render_diff_image

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;
}
开发者ID:hexcode007,项目名称:yfcms,代码行数:17,代码来源:callgraph_utils.php

示例4: profiler_report

/**
 * 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];
//.........这里部分代码省略.........
开发者ID:shourya07,项目名称:zperfmon,代码行数:101,代码来源:xhprof.php


注:本文中的xhprof_compute_diff函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。