Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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"];
}
Exemplo n.º 4
0
function combine_files($files, $game_name, $pattern, $output)
{
    $combined = array();
    $matches = null;
    #$pattern = "/[0-9]+\.(.*)\.extract/";
    foreach ($files as $file) {
        if (preg_match($pattern, basename($file), $matches)) {
            $key = $matches[1];
            $combined[$key] = XHProfRuns_Default::load_profile($file);
        }
    }
    file_put_contents($output, serialize($combined));
}
Exemplo n.º 5
0
function to_array($filename)
{
    if (!file_exists($filename)) {
        return null;
    }
    $array = null;
    try {
        $array = XHProfRuns_Default::load_profile($filename);
    } catch (Exception $ex) {
        var_dump($ex->getTrace());
    }
    return $array;
}