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


PHP xhprof_parse_parent_child函数代码示例

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


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

示例1: symbol_report


//.........这里部分代码省略.........
    print "</td></tr>";
    print "<tr>";
    // make this a self-reference to facilitate copy-pasting snippets to e-mails
    print "<td><a href=''>{$rep_symbol}</a>";
    print_source_link(array('fn' => $rep_symbol));
    print "</td>";
    if ($display_calls) {
        // Call Count
        print_td_num($symbol_info["ct"], $format_cbk["ct"]);
        print_td_pct($symbol_info["ct"], $totals["ct"]);
    }
    // Inclusive Metrics for current function
    foreach ($metrics as $metric) {
        print_td_num($symbol_info[$metric], $format_cbk[$metric], $sort_col == $metric);
        print_td_pct($symbol_info[$metric], $totals[$metric], $sort_col == $metric);
    }
    print "</tr>";
    print "<tr bgcolor='#ffffff'>";
    print "<td style='text-align:right;color:blue'>" . "Exclusive Metrics {$diff_text} for Current Function</td>";
    if ($display_calls) {
        // Call Count
        print "<td {$vbar}></td>";
        print "<td {$vbar}></td>";
    }
    // Exclusive Metrics for current function
    foreach ($metrics as $metric) {
        print_td_num($symbol_info["excl_" . $metric], $format_cbk["excl_" . $metric], $sort_col == $metric, get_tooltip_attributes("Child", $metric));
        print_td_pct($symbol_info["excl_" . $metric], $symbol_info[$metric], $sort_col == $metric, get_tooltip_attributes("Child", $metric));
    }
    print "</tr>";
    // list of callers/parent functions
    $results = array();
    if ($display_calls) {
        $base_ct = $symbol_info["ct"];
    } else {
        $base_ct = 0;
    }
    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) {
        print_pc_array($url_params, $results, $base_ct, $base_info, true, $run1, $run2);
    }
    // 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;
            if ($display_calls) {
                $base_ct += $info["ct"];
            }
        }
    }
    usort($results, 'sort_cbk');
    if (count($results)) {
        print_pc_array($url_params, $results, $base_ct, $base_info, false, $run1, $run2);
    }
    print "</table>";
    // These will be used for pop-up tips/help.
    // Related javascript code is in: xhprof_report.js
    print "\n";
    print '<script language="javascript">' . "\n";
    print "var func_name = '\"" . $rep_symbol . "\"';\n";
    print "var total_child_ct  = " . $base_ct . ";\n";
    if ($display_calls) {
        print "var func_ct   = " . $symbol_info["ct"] . ";\n";
    }
    print "var func_metrics = new Array();\n";
    print "var metrics_col  = new Array();\n";
    print "var metrics_desc  = new Array();\n";
    if ($diff_mode) {
        print "var diff_mode = true;\n";
    } else {
        print "var diff_mode = false;\n";
    }
    $column_index = 3;
    // First three columns are Func Name, Calls, Calls%
    foreach ($metrics as $metric) {
        print "func_metrics[\"" . $metric . "\"] = " . round($symbol_info[$metric]) . ";\n";
        print "metrics_col[\"" . $metric . "\"] = " . $column_index . ";\n";
        print "metrics_desc[\"" . $metric . "\"] = \"" . $possible_metrics[$metric][2] . "\";\n";
        // each metric has two columns..
        $column_index += 2;
    }
    print '</script>';
    print "\n";
}
开发者ID:bdlangton,项目名称:xhprof-1,代码行数:101,代码来源:xhprof.php

示例2: xhprof_generate_dot_script

/**
 * Generate DOT script from the given raw phprof data.
 *
 * @param raw_data, phprof profile data.
 * @param threshold, float, the threshold value [0,1). The functions in the
 *                   raw_data whose exclusive wall times ratio are below the
 *                   threshold will be filtered out and won't apprear in the
 *                   generated image.
 * @param page, string(optional), the root node name. This can be used to
 *              replace the 'main()' as the root node.
 * @param func, string, the focus function.
 * @param critical_path, bool, whether or not to display critical path with
 *                             bold lines.
 * @returns, string, the DOT script to generate image.
 *
 * @author cjiang
 */
function xhprof_generate_dot_script($raw_data, $threshold, $source, $page, $func, $critical_path, $right = null, $left = null)
{
    $max_width = 5;
    $max_height = 3.5;
    $max_fontsize = 35;
    $max_sizing_ratio = 20;
    $totals;
    if ($left === null) {
        // init_metrics($raw_data, null, null);
    }
    $sym_table = xhprof_compute_flat_info($raw_data, $totals);
    if ($critical_path) {
        $children_table = xhprof_get_children_table($raw_data);
        $node = "main()";
        $path = array();
        $path_edges = array();
        $visited = array();
        while ($node) {
            $visited[$node] = true;
            if (isset($children_table[$node])) {
                $max_child = null;
                foreach ($children_table[$node] as $child) {
                    if (isset($visited[$child])) {
                        continue;
                    }
                    if ($max_child === null || abs($raw_data[xhprof_build_parent_child_key($node, $child)]["wt"]) > abs($raw_data[xhprof_build_parent_child_key($node, $max_child)]["wt"])) {
                        $max_child = $child;
                    }
                }
                if ($max_child !== null) {
                    $path[$max_child] = true;
                    $path_edges[xhprof_build_parent_child_key($node, $max_child)] = true;
                }
                $node = $max_child;
            } else {
                $node = null;
            }
        }
    }
    // if it is a benchmark callgraph, we make the benchmarked function the root.
    if ($source == "bm" && array_key_exists("main()", $sym_table)) {
        $total_times = $sym_table["main()"]["ct"];
        $remove_funcs = array("main()", "hotprofiler_disable", "call_user_func_array", "xhprof_disable");
        foreach ($remove_funcs as $cur_del_func) {
            if (array_key_exists($cur_del_func, $sym_table) && $sym_table[$cur_del_func]["ct"] == $total_times) {
                unset($sym_table[$cur_del_func]);
            }
        }
    }
    // use the function to filter out irrelevant functions.
    if (!empty($func)) {
        $interested_funcs = array();
        foreach ($raw_data as $parent_child => $info) {
            list($parent, $child) = xhprof_parse_parent_child($parent_child);
            if ($parent == $func || $child == $func) {
                $interested_funcs[$parent] = 1;
                $interested_funcs[$child] = 1;
            }
        }
        foreach ($sym_table as $symbol => $info) {
            if (!array_key_exists($symbol, $interested_funcs)) {
                unset($sym_table[$symbol]);
            }
        }
    }
    $result = "digraph call_graph {\n";
    // Filter out functions whose exclusive time ratio is below threshold, and
    // also assign a unique integer id for each function to be generated. In the
    // meantime, find the function with the most exclusive time (potentially the
    // performance bottleneck).
    $cur_id = 0;
    $max_wt = 0;
    foreach ($sym_table as $symbol => $info) {
        if (empty($func) && abs($info["wt"] / $totals["wt"]) < $threshold) {
            unset($sym_table[$symbol]);
            continue;
        }
        if ($max_wt == 0 || $max_wt < abs($info["excl_wt"])) {
            $max_wt = abs($info["excl_wt"]);
        }
        $sym_table[$symbol]["id"] = $cur_id;
        $cur_id++;
    }
//.........这里部分代码省略.........
开发者ID:hexcode007,项目名称:yfcms,代码行数:101,代码来源:callgraph_utils.php

示例3: xhprof_get_matching_functions

/**
 * Given a partial query string $q return matching function names in
 * specified XHProf run. This is used for the type ahead function
 * selector.
 *
 * @author Kannan
 */
function xhprof_get_matching_functions($q, $xhprof_data)
{
    $matches = array();
    foreach ($xhprof_data as $parent_child => $info) {
        list($parent, $child) = xhprof_parse_parent_child($parent_child);
        if (stripos($parent, $q) !== false) {
            $matches[$parent] = 1;
        }
        if (stripos($child, $q) !== false) {
            $matches[$child] = 1;
        }
    }
    $res = array_keys($matches);
    // sort it so the answers are in some reliable order...
    asort($res);
    return $res;
}
开发者ID:gggeek,项目名称:ezperformancelogger,代码行数:24,代码来源:xhprof_lib.php

示例4: symbol_report


//.........这里部分代码省略.........
    print "<tr bgcolor='#e0e0ff'><td>";
    print "<b><i><center>Current Function</center></i></b>";
    print "</td></tr>";
    print "<tr>";
    // make this a self-reference to facilitate copy-pasting snippets to e-mails
    print "<td><a href=''>{$rep_symbol}</a></td>";
    if ($display_calls) {
        // Call Count
        print_td_num($symbol_info["ct"], $format_cbk["ct"]);
        print_td_pct($symbol_info["ct"], $totals["ct"]);
    }
    // Inclusive Metrics for current function
    foreach ($metrics as $metric) {
        print_td_num($symbol_info[$metric], $format_cbk[$metric], $sort_col == $metric);
        print_td_pct($symbol_info[$metric], $totals[$metric], $sort_col == $metric);
    }
    print "</tr>";
    print "<tr bgcolor='#ffffff'>";
    print "<td style='text-align:right;color:blue'>" . "Exclusive Metrics {$diff_text} for Current Function</td>";
    if ($display_calls) {
        // Call Count
        print "<td {$vbar}></td>";
        print "<td {$vbar}></td>";
    }
    // Exclusive Metrics for current function
    foreach ($metrics as $metric) {
        print_td_num($symbol_info["excl_" . $metric], $format_cbk["excl_" . $metric], $sort_col == $metric, get_tooltip_attributes("Child", $metric));
        print_td_pct($symbol_info["excl_" . $metric], $symbol_info[$metric], $sort_col == $metric, get_tooltip_attributes("Child", $metric));
    }
    print "</tr>";
    // list of callers/parent functions
    $results = array();
    if ($display_calls) {
        $base_ct = $symbol_info["ct"];
    } else {
        $base_ct = 0;
    }
    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) {
        print_pc_array($url_params, $results, $base_ct, $base_info, true, $run1, $run2);
    }
    // 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;
            if ($display_calls) {
                $base_ct += $info["ct"];
            }
        }
    }
    usort($results, 'sort_cbk');
    if (count($results)) {
        print_pc_array($url_params, $results, $base_ct, $base_info, false, $run1, $run2);
    }
    print "</table>";
    // These will be used for pop-up tips/help.
    // Related javascript code is in: xhprof_report.js
    print "\n";
    print '<script language="javascript">' . "\n";
    print "var func_name = '\"" . $rep_symbol . "\"';\n";
    print "var total_child_ct  = " . $base_ct . ";\n";
    if ($display_calls) {
        print "var func_ct   = " . $symbol_info["ct"] . ";\n";
    }
    print "var func_metrics = new Array();\n";
    print "var metrics_col  = new Array();\n";
    print "var metrics_desc  = new Array();\n";
    if ($diff_mode) {
        print "var diff_mode = true;\n";
    } else {
        print "var diff_mode = false;\n";
    }
    $column_index = 3;
    // First three columns are Func Name, Calls, Calls%
    foreach ($metrics as $metric) {
        print "func_metrics[\"" . $metric . "\"] = " . round($symbol_info[$metric]) . ";\n";
        print "metrics_col[\"" . $metric . "\"] = " . $column_index . ";\n";
        print "metrics_desc[\"" . $metric . "\"] = \"" . $possible_metrics[$metric][2] . "\";\n";
        // each metric has two columns..
        $column_index += 2;
    }
    print '</script>';
    print "\n";
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:101,代码来源:xhprof.php

示例5: render

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

示例6: xhprof_get_matching_functions

/**
 * Given a partial query string $q return matching function names in
 * specified XHProf run. This is used for the type ahead function
 * selector.
 *
 * @author Kannan
 */
function xhprof_get_matching_functions($q, $xhprof_data)
{
    $matches = array();
    foreach ($xhprof_data as $parent_child => $info) {
        list($parent, $child) = xhprof_parse_parent_child($parent_child);
        if (stripos($child, $q) !== false) {
            if (!isset($matches[$child])) {
                $matches[$child] = array('ct' => $info['ct'], 'wt' => $info['wt'], 'bcc' => (int) $info['bcc'], 'value' => $child);
            } else {
                $matches[$child]['ct'] += $info['ct'];
                $matches[$child]['wt'] += $info['wt'];
            }
        }
    }
    // sort it so the answers are in some reliable order...
    ksort($matches);
    return $matches;
}
开发者ID:sugarcrm,项目名称:xhprof-viewer,代码行数:25,代码来源:xhprof_lib.php


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