コード例 #1
0
ファイル: profilepie.inc.php プロジェクト: shourya07/zperfmon
function get_pie($game_name, $period = "day", $tstamp = null, $metrics = array("excl_wt" => "Exclusive Wall time", "excl_cpu" => "Exclusive CPU time"), $how_many = 6, $profile = null)
{
    global $server_cfg;
    $game_cfg = load_game_config($game_name);
    //$game_cfg = $game_cfg["$game_name"];
    if ($profile != null) {
        $period = "absolute";
    }
    switch ($period) {
        case "day":
            $prof_path = sprintf($server_cfg["daily_profile"], $game_cfg["name"]);
            break;
        case "30min":
            $prof_path = sprintf($server_cfg["daily_upload_directory"], $game_cfg["name"]);
            break;
        case "absolute":
            break;
        default:
            echo "Unsupported period \\'{$period}\\' for get_pie()";
            error_log("Unsupported period \\'{$period}\\' for get_pie()");
            return null;
    }
    if ($period != "absolute") {
        // Find all aggregate profiles in dir and take the last
        $profile_list = glob("{$prof_path}/*all.xhprof");
        if (empty($profile_list)) {
            echo "no profile in {$period} {$prof_path}/*.all.xhprof";
            return null;
        }
        $profile = end($profile_list);
    }
    return get_top_functions($profile, $metrics, $how_many);
}
コード例 #2
0
ファイル: profilepie.inc.php プロジェクト: shourya07/zperfmon
function get_pie($server_cfg, $game_cfg, $period = "day", $tstamp = null, $metrics = array("excl_wt" => "Exclusive Wall time", "excl_cpu" => "Exclusive CPU time"), $how_many = 6, $profile = null, $pages = null)
{
    if ($profile != null) {
        $period = "absolute";
        $metrics = array("excl_wt" => "Exclusive Wall time", "excl_cpu" => "Exclusive CPU time");
        $how_many = 6;
    }
    switch ($period) {
        case "day":
            $prof_path = sprintf($server_cfg["daily_profile"], $game_cfg["name"]);
            break;
        case "30min":
            $prof_path = sprintf($server_cfg["daily_upload_directory"], $game_cfg["name"]);
            break;
        case "absolute":
            break;
        default:
            echo "Unsupported period \\'{$period}\\' for get_pie()";
            error_log("Unsupported period \\'{$period}\\' for get_pie()");
            return null;
    }
    if ($period != "absolute") {
        // Find all aggregate profiles in dir and take the last
        $profile_list = glob("{$prof_path}/*all.xhprof");
        if (empty($profile_list)) {
            //echo "no profile in $period $prof_path/*.all.xhprof";
            return null;
        }
        $profile = end($profile_list);
    }
    /* now create an array whih contains data,
     *	 for all the pages and return an object,
     *	 having page name as key and data as their value 
     */
    $top_fn = array();
    $page_data = array();
    if ($pages != null) {
        foreach ($pages as $page) {
            $profile_list = glob("{$prof_path}/*{$page}.xhprof");
            if (empty($profile_list)) {
                //echo "no profile in $period $prof_path/*.all.xhprof";
                continue;
            }
            $profile = end($profile_list);
            $page_data[$page] = get_top_functions($profile, $metrics, $how_many);
            $top_fn = array_merge($top_fn, $page_data);
        }
        return $top_fn;
    } else {
        return get_top_functions($profile, $metrics, $how_many);
    }
}
コード例 #3
0
ファイル: aggregate.php プロジェクト: shourya07/zperfmon
function extract_functions($files, $game_name, $run_id, $aggregate_dir)
{
    // XXX: xhprof depends on this global for doing entry counts
    global $display_calls;
    $display_calls = true;
    $functions_to_extract = array("MC::set", "MC::get", "ApcManager::get", "ApcManager::set", "serialize", "unserialize", "AMFBaseSerializer::serialize", "AMFBaseDeserializer::deserialize");
    if ($game_cfg = load_game_config($game_name)) {
        //$game_cfg = $game_cfg[$game_name];
        if (isset($game_cfg["tracked_functions"])) {
            $functions_to_extract = $game_cfg["tracked_functions"];
        }
    }
    $prof_obj = new XHProfRuns_Default();
    $runs = xhprof_aggregate_runs_list($prof_obj, $files);
    if ($runs['raw']) {
        $aggregate = $runs['raw'];
    } else {
        return;
    }
    # keep this in sync with the aggregate_files
    # $aggregate_file_name = "{$run_id}.xhprof";
    $overall_totals = null;
    $flattened_profile = xhprof_compute_flat_info($aggregate, $overall_totals);
    $interesting_funcs = extract_interesting_functions($flattened_profile, $functions_to_extract);
    $top_funcs = get_top_functions($flattened_profile, 5);
    $xhprof = array("interesting" => $interesting_funcs, "top functions" => $top_funcs, "files" => $files);
    file_put_contents("{$aggregate_dir}/{$run_id}.extract", serialize($xhprof));
}