How to use the pyinstrument.stat_profiler.StatFrame function in pyinstrument

To help you get started, weā€™ve selected a few pyinstrument examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joerick / pyinstrument / pyinstrument / stat_profiler.py View on Github external
def frame_for_stack(stack):
                if len(stack) == 0:
                    return self._root_frame

                parent = frame_for_stack(stack[:-1])
                frame_name = stack[-1]

                if not frame_name in parent.children:
                    parent.children[frame_name] = StatFrame(frame_name, parent)

                return parent.children[frame_name]
github joerick / pyinstrument / pyinstrument / stat_profiler.py View on Github external
def __init__(self, *args, **kwargs):
        super(StatFrame, self).__init__(*args, **kwargs)
        self.self_time = 0
github joerick / pyinstrument / pyinstrument / stat_profiler.py View on Github external
def root_frame(self):
        """
        Returns the parsed results in the form of a tree of Frame objects
        """
        if not hasattr(self, '_root_frame'):
            self._root_frame = StatFrame()

            # define a recursive function that builds the heirarchy of frames given the
            # stack of frame identifiers
            def frame_for_stack(stack):
                if len(stack) == 0:
                    return self._root_frame

                parent = frame_for_stack(stack[:-1])
                frame_name = stack[-1]

                if not frame_name in parent.children:
                    parent.children[frame_name] = StatFrame(frame_name, parent)

                return parent.children[frame_name]

            for stack, self_time in self.stack_self_time.iteritems():