How to use the pyinstrument.frame.Frame 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 / test / test_processors.py View on Github external
def test_group_library_frames_processor():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='library_function\x00env/lib/python3.6/django/__init__.py\x00997',
                children=[
                    Frame(
                        identifier='library_inner\x00env/lib/python3.6/django/http.py\x0054',
                        children=[
                            Frame(
                                identifier='library_callback\x00env/lib/python3.6/django/views.py\x0054',
                                children=[
                                    Frame(
                                        identifier='\x00cibuildwheel/views.py\x0012',
                                        self_time=0.3,
                                    ),
                                ]
                            ),
                        ]
                    ),
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_group_library_frames_processor():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='library_function\x00env/lib/python3.6/django/__init__.py\x00997',
                children=[
                    Frame(
                        identifier='library_inner\x00env/lib/python3.6/django/http.py\x0054',
                        children=[
                            Frame(
                                identifier='library_callback\x00env/lib/python3.6/django/views.py\x0054',
                                children=[
                                    Frame(
                                        identifier='\x00cibuildwheel/views.py\x0012',
                                        self_time=0.3,
                                    ),
                                ]
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_merge_consecutive_self_time():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                self_time=0.1),
            SelfTimeFrame(
                self_time=0.2,
            ),
            SelfTimeFrame(
                self_time=0.1,
            ),
            Frame(
                identifier='calculate_metrics\x00cibuildwheel/utils.py\x007',
                self_time=0.1),
            SelfTimeFrame(
                self_time=0.05,
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_remove_irrelevant_nodes():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                children=[
                    Frame(
                        identifier='scan_string\x00cibuildwheel/utils.py\x0054',
                        self_time=10,
                    ),
                ]
            ),
            SelfTimeFrame(
                self_time=0.5,
            ),
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_remove_irrelevant_nodes():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                children=[
                    Frame(
                        identifier='scan_string\x00cibuildwheel/utils.py\x0054',
                        self_time=10,
                    ),
                ]
            ),
            SelfTimeFrame(
                self_time=0.5,
            ),
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                self_time=0.5,
            ),
            Frame(
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_remove_unnecessary_self_time_nodes():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                children=[
                    SelfTimeFrame(
                        self_time=0.2,
                    ),
                ]
            ),
            SelfTimeFrame(
                self_time=0.5,
            ),
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                self_time=0.5,
            ),
            Frame(
                identifier='calculate_metrics\x00cibuildwheel/utils.py\x007',
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_aggregate_repeated_calls():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                self_time=0.1,
                children=[
                    Frame(
                        identifier='scan_string\x00cibuildwheel/utils.py\x0054',
                        self_time=0.2,
                    ),
                ]
            ),
            SelfTimeFrame(
                self_time=0.1,
            ),
            Frame(
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_remove_importlib():
    frame = Frame(
        identifier='\x00sympy/__init__.py\x0012',
        children=[
            Frame(
                identifier='_handle_fromlist\x00../\x00997',
                self_time=0.1,
                children=[
                    Frame(
                        identifier='_find_and_load\x00../\x00997',
                        self_time=0.1,
                        children=[
                            Frame(
                                identifier='\x00sympy/polys/polyfuncs.py\x001',
                                self_time=0.05,
                            ),
                            Frame(
                                identifier='\x00sympy/polys/partfrac.py\x001',
                                self_time=0.2,
                            )
                        ]
                    ),
                    Frame(
                        identifier='\x00sympy/polys/numberfields.py\x001',
                        self_time=0.05,
                    )
                ]
            )
        ]
github joerick / pyinstrument / test / test_processors.py View on Github external
def test_group_library_frames_processor():
    frame = Frame(
        identifier='\x00cibuildwheel/__init__.py\x0012',
        children=[
            Frame(
                identifier='library_function\x00env/lib/python3.6/django/__init__.py\x00997',
                children=[
                    Frame(
                        identifier='library_inner\x00env/lib/python3.6/django/http.py\x0054',
                        children=[
                            Frame(
                                identifier='library_callback\x00env/lib/python3.6/django/views.py\x0054',
                                children=[
                                    Frame(
                                        identifier='\x00cibuildwheel/views.py\x0012',
                                        self_time=0.3,
                                    ),
                                ]
                            ),
                        ]
                    ),
                ]
            ),
            SelfTimeFrame(
                self_time=0.5,
            ),
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                self_time=0.5,
            ),
github joerick / pyinstrument / pyinstrument / session.py View on Github external
frame_stack = []

        for frame_tuple in self.frame_records:
            identifier_stack = frame_tuple[0]
            time = frame_tuple[1]

            # now we must create a stack of frame objects and assign this time to the leaf
            for stack_depth, frame_identifier in enumerate(identifier_stack):
                if stack_depth < len(frame_stack):
                    if frame_identifier != frame_stack[stack_depth].identifier:
                        # trim any frames after and including this one
                        del frame_stack[stack_depth:]

                if stack_depth >= len(frame_stack):
                    frame = Frame(frame_identifier)
                    frame_stack.append(frame)
                    
                    if stack_depth == 0:
                        # There should only be one root frame, as far as I know
                        assert root_frame is None, ASSERTION_MESSAGE
                        root_frame = frame
                    else:
                        parent = frame_stack[stack_depth-1]
                        parent.add_child(frame)

            # trim any extra frames
            del frame_stack[stack_depth+1:]  # pylint: disable=W0631

            # assign the time to the final frame
            frame_stack[-1].add_child(SelfTimeFrame(self_time=time))