Exemple #1
0
def cpuprofile_generate_flame_graph(file_path, range_start, range_end):
    f = get_file(file_path)
    chrome_profile = json.load(f)
    f.close()

    cpuprofiles = get_cpuprofiles(chrome_profile)

    # a chrome profile can contain multiple cpu profiles
    # using only the first one for now
    # TODO: add support for multiple cpu profiles
    profile = cpuprofiles[0]

    root_id = profile['nodes'][0]['id']
    nodes = parse_nodes(profile)
    ignore_ids = get_meta_ids(nodes)
    start_time = profile['startTime']
    if range_start is not None:
        adjusted_range_start = (math.floor(start_time / 1000000) +
                                range_start) * 1000000
    if range_end is not None:
        adjusted_range_end = (math.floor(start_time / 1000000) +
                              range_end) * 1000000

    return generate_flame_graph(nodes, root_id, profile['samples'],
                                profile['timeDeltas'], profile['startTime'],
                                adjusted_range_start, adjusted_range_end,
                                ignore_ids)
Exemple #2
0
def nflxprofile_generate_differential_flame_graph(file_path, range_start, range_end):
    try:
        f = get_file(file_path)
        profile = nflxprofile_pb2.Profile()
        profile.ParseFromString(f.read())
    except TypeError:
        abort(500, 'Failed to parse profile.')
    finally:
        f.close()

    start_time = profile.start_time
    if range_start is not None:
        range_start = (math.floor(start_time) + range_start)
    if range_end is not None:
        range_end = (math.floor(start_time) + range_end)

    return generate_flame_graph([profile], [0], [None], range_start, range_end)
Exemple #3
0
def nflxprofile_generate_flame_graph(file_path, range_start, range_end):
    try:
        f = get_file(file_path)
        profile = nflxprofile_pb2.Profile()
        profile.ParseFromString(f.read())
    except TypeError:
        abort(500, 'Failed to parse profile.')
    finally:
        f.close()

    start_time = profile.start_time
    if range_start is not None:
        adjusted_range_start = (math.floor(start_time) + range_start)
    if range_end is not None:
        adjusted_range_end = (math.floor(start_time) + range_end)

    return generate_flame_graph(profile.nodes, 0, profile.samples, profile.time_deltas, start_time, adjusted_range_start, adjusted_range_end, None)
Exemple #4
0
def cpuprofile_generate_flame_graph(file_path, range_start, range_end):
    f = get_file(file_path)
    chrome_profile = json.load(f)
    f.close()

    profiles = get_cpuprofiles(chrome_profile)
    root_ids = []
    ignore_ids = []
    start_time = None

    for profile in profiles:
        root_ids.append(profile['nodes'][0]['id'])
        parsed_nodes = parse_nodes(profile['nodes'])
        ignore_ids.append(get_meta_ids(parsed_nodes))
        profile['nodes'] = parsed_nodes
        if start_time is None or profile['startTime'] < start_time:
            start_time = profile['startTime']

    if range_start is not None:
        adjusted_range_start = (math.floor(start_time / 1000000) + range_start) * 1000000
    if range_end is not None:
        adjusted_range_end = (math.floor(start_time / 1000000) + range_end) * 1000000

    return generate_flame_graph(profiles, root_ids, ignore_ids, adjusted_range_start, adjusted_range_end)
Exemple #5
0
def cpuprofile_generate_flame_graph(filename,
                                    range_start,
                                    range_end,
                                    profile=None):
    if not profile:
        file_path = join(config.PROFILE_DIR, filename)
        (f, mime) = get_file(file_path)
        profile = json.load(f)
        f.close()

    nodes = parse_nodes(profile)
    ignore_ids = get_meta_ids(nodes)
    start_time = profile['startTime']
    if range_start is not None:
        adjusted_range_start = (math.floor(start_time / 1000000) +
                                range_start) * 1000000
    if range_end is not None:
        adjusted_range_end = (math.floor(start_time / 1000000) +
                              range_end) * 1000000

    return generate_flame_graph(nodes, profile['samples'],
                                profile['timeDeltas'], profile['startTime'],
                                adjusted_range_start, adjusted_range_end,
                                ignore_ids)