How to use the pyinstrument.processors.group_library_frames_processor 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
import sys
from pyinstrument import processors
from pyinstrument.frame import Frame, SelfTimeFrame
from pytest import approx

all_processors = [
    processors.aggregate_repeated_calls,
    processors.group_library_frames_processor,
    processors.merge_consecutive_self_time,
    processors.remove_importlib,
    processors.remove_unnecessary_self_time_nodes,
    processors.remove_irrelevant_nodes,
]

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',
github joerick / pyinstrument / test / test_processors.py View on Github external
self_time=0.5,
            ),
            Frame(
                identifier='strip_newlines\x00cibuildwheel/utils.py\x00997',
                self_time=0.5,
            ),
            Frame(
                identifier='calculate_metrics\x00cibuildwheel/utils.py\x007',
                self_time=0.1,
            ),
        ]
    )

    assert frame.time() == approx(1.4)

    frame = processors.group_library_frames_processor(frame, options={})

    assert frame.time() == approx(1.4)
    group_root = frame.children[0]

    group = group_root.group
    assert group.root == group_root

    for frame in group.frames:
        assert frame.group == group

    assert group_root in group.frames
    assert group_root.children[0] in group.frames
    assert group_root.children[0].children[0] in group.frames
    assert group_root.children[0].children[0] in group.exit_frames
    assert group_root.children[0].children[0].children[0] not in group.frames
github joerick / pyinstrument / pyinstrument / renderers / jsonrenderer.py View on Github external
def default_processors(self):
        return [
            processors.remove_importlib,
            processors.merge_consecutive_self_time,
            processors.aggregate_repeated_calls,
            processors.group_library_frames_processor,
            processors.remove_unnecessary_self_time_nodes,
            processors.remove_irrelevant_nodes,
        ]
github joerick / pyinstrument / pyinstrument / renderers / base.py View on Github external
def __init__(self, show_all=False, timeline=False, processor_options=None):
        # processors is defined on the base class to provide a common way for users to
        # add to and manipulate them before calling render()
        self.processors = self.default_processors()
        self.processor_options = processor_options or {}

        if show_all:
            self.processors.remove(processors.group_library_frames_processor)
        if timeline:
            self.processors.remove(processors.aggregate_repeated_calls)
github joerick / pyinstrument / pyinstrument / renderers / html.py View on Github external
def default_processors(self):
        return [
            processors.remove_importlib,
            processors.merge_consecutive_self_time,
            processors.aggregate_repeated_calls,
            processors.group_library_frames_processor,
            processors.remove_unnecessary_self_time_nodes,
            processors.remove_irrelevant_nodes,
        ]
github joerick / pyinstrument / pyinstrument / renderers / console.py View on Github external
def default_processors(self):
        return [
            processors.remove_importlib,
            processors.merge_consecutive_self_time,
            processors.aggregate_repeated_calls,
            processors.group_library_frames_processor,
            processors.remove_unnecessary_self_time_nodes,
            processors.remove_irrelevant_nodes,
        ]