vprof/flame_graph.py
def _insert_stack(stack, sample_count, call_tree):
        """Inserts stack into the call tree.

        Args:
            stack: Call stack.
            sample_count: Sample count of call stack.
            call_tree: Call tree.
        """
        curr_level = call_tree
        for func in stack:
            next_level_index = {
                node['stack']: node for node in curr_level['children']}
            if func not in next_level_index:
                new_node = {'stack': func, 'children': [], 'sampleCount': 0}
                curr_level['children'].append(new_node)
                curr_level = new_node
            else:
                curr_level = next_level_index[func]
        curr_level['sampleCount'] = sample_count
def _insert_stack(stack, sample_count, call_tree):
        curr_level = call_tree
        for func in stack:
            next_level_index = {
                node['stack']: node for node in curr_level['children']}
            if func not in next_level_index:
                new_node = {'stack': func, 'children': [], 'sampleCount': 0}
                curr_level['children'].append(new_node)
                curr_level = new_node
            else:
                curr_level = next_level_index[func]
        curr_level['sampleCount'] = sample_count
def _insert_stack ( stack , sample_count , call_tree ) : curr_level = call_tree for func in stack : next_level_index = { node [ 'stack' ] : node for node in curr_level [ 'children' ] } if func not in next_level_index : new_node = { 'stack' : func , 'children' : [ ] , 'sampleCount' : 0 } curr_level [ 'children' ] . append ( new_node ) curr_level = new_node else : curr_level = next_level_index [ func ] curr_level [ 'sampleCount' ] = sample_count
Inserts stack into the call tree.

        Args:
            stack: Call stack.
            sample_count: Sample count of call stack.
            call_tree: Call tree.
Inserts stack into the call tree .