How to use the pyinstrument.event_profiler.EventFrame 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 / event_profiler.py View on Github external
def __init__(self, *args, **kwargs):
        super(EventFrame, self).__init__(*args, **kwargs)
        self.time = 0
github joerick / pyinstrument / pyinstrument / event_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] = EventFrame(frame_name, parent)

                return parent.children[frame_name]
github joerick / pyinstrument / pyinstrument / event_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 = EventFrame()

            # 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] = EventFrame(frame_name, parent)

                return parent.children[frame_name]

            for stack_frame in self.stack_time.iteritems():