def test_heap_map(memory_profiles):
    """Test creation of heap map out of the profile of memory type

    Expecting no errors and returned dictionary with internal format of the heap map
    """
    for memory_profile in memory_profiles:
        heap_map = convert.to_heap_map_format(memory_profile)
        assert len(heap_map['snapshots']) == len(memory_profile['snapshots'])
示例#2
0
文件: run.py 项目: xlisci02/perun
def _call_heap(profile):
    """ Call interactive heap map visualization

    :param dict profile: memory profile with records
    """
    heap_map = heap_representation.to_heap_map_format(deepcopy(profile))
    heat_map = heap_representation.to_heat_map_format(profile)
    hm.heap_map(heap_map, heat_map)
示例#3
0
def test_heap_and_heat_logic(mock_curses_window, monkeypatch, memory_profiles):
    """Test heap map and heat map together with their logics

    Expecting no error, printed information and everything correct
    """
    monkeypatch.setattr(curses, 'napms', donothing)
    monkeypatch.setattr(curses, 'curs_set', donothing)
    monkeypatch.setattr(curses, 'color_pair', returnnothing)

    for memory_profile in memory_profiles:
        heap_map_repr = convert.to_heap_map_format(deepcopy(memory_profile))
        heat_map_repr = convert.to_heat_map_format(memory_profile)
        colour_mode = heap_colours.HeapMapColors.NO_COLORS
        heap_map.heap_map_logic(mock_curses_window, heap_map_repr,
                                heat_map_repr, colour_mode)
示例#4
0
def test_curses_logic(monkeypatch, mock_curses_window, memory_profiles):
    """Test logic of the flow visualization

    Expecting no errors, eventually the visualization should end.
    """
    monkeypatch.setattr(curses, 'curs_set', donothing)
    monkeypatch.setattr(curses, 'color_pair', returnnothing)
    monkeypatch.setattr(curses, 'start_color', donothing)
    monkeypatch.setattr(curses, 'use_default_colors', donothing)
    monkeypatch.setattr(curses, 'napms', donothing)

    # Rewrite the sequence of the mock window
    mock_curses_window.character_stream = iter(
        [ord('i'), ord('i'), curses.KEY_RIGHT,
         ord('q'), ord('q')])

    for memory_profile in memory_profiles:
        heap_map = convert.to_heap_map_format(memory_profile)
        curses_graphs.flow_graph_logic(mock_curses_window, heap_map)
示例#5
0
def test_curses_flow(monkeypatch, mock_curses_window, memory_profiles):
    """Test creating showing curses graph

    Expecting no errors
    """
    monkeypatch.setattr(curses, 'curs_set', donothing)
    monkeypatch.setattr(curses, 'color_pair', returnnothing)
    monkeypatch.setattr(curses, 'start_color', donothing)
    monkeypatch.setattr(curses, 'use_default_colors', donothing)
    monkeypatch.setattr(curses, 'napms', donothing)

    for memory_profile in memory_profiles:
        heap_map = convert.to_heap_map_format(memory_profile)
        vis_obj = curses_graphs.FlowGraphVisualization(mock_curses_window,
                                                       heap_map)
        vis_obj.print_intro()
        vis_obj.print_resize_req()
        vis_obj.print_global_view()
        str_window = str(mock_curses_window)
        assert 'MEMORY' in str_window
        y, x = mock_curses_window.getmaxyx()
        assert ('|' + ' ' * x + '|') not in str_window
示例#6
0
def test_heap_map(mock_curses_window, monkeypatch, memory_profiles):
    """Test heap map without the logic and anything, according to the mock window

    Expecting no error and some output to the mocked curses window
    """
    monkeypatch.setattr(curses, 'curs_set', donothing)
    monkeypatch.setattr(curses, 'color_pair', returnnothing)

    for memory_profile in memory_profiles:
        heap_map_representation = convert.to_heap_map_format(memory_profile)
        hm_visualization = heap_map.HeapMapVisualization(
            mock_curses_window, heap_map_representation,
            heap_colours.HeapMapColors.NO_COLORS)
        hm_visualization.draw_heap_map()
        hm_visualization.following_snapshot(
            heap_map.HeapMapVisualization.NEXT_SNAPSHOT)

        str_window = str(mock_curses_window)
        assert str(
            heap_map_representation['stats']['min_address']) in str_window
        # Correctly shows the ticks
        for tick in map(str, range(0, 110, 17)):
            assert tick in str_window
        assert "1/{}".format(len(memory_profile['snapshots'])) in str_window
示例#7
0
def flow(profile, use_terminal, filename, view_in_browser, **kwargs):
    """Customizable interpretation of resources using the flow format.

    .. _Bokeh: https://bokeh.pydata.org/en/latest/

    \b
      * **Limitations**: `none`.
      * **Interpretation style**: graphical, textual
      * **Visualization backend**: Bokeh_, ncurses

    `Flow` graph shows the values resources depending on the independent
    variable as basic graph. For each group of resources identified by unique
    value of ``<by>`` key, one graph shows the dependency of ``<of>`` values
    aggregated by ``<func>`` depending on the ``<through>`` key. Moreover, the
    values can either be accumulated (this way when displaying the value of 'n'
    on x axis, we accumulate the sum of all values for all m < n) or stacked,
    where the graphs are output on each other and then one can see the overall
    trend through all the groups and proportions between each of the group.

    Bokeh_ library is the current interpretation backend, which generates HTML
    files, that can be opened directly in the browser. Resulting graphs can be
    further customized by adding custom labels for axes, custom graph title or
    different graph width.

    Example 1. The following will show the average amount (in this case
    the function running time) of each function depending on the size of the
    structure over which the given function operated::

        perun show 0@i flow mean --of 'amount' --per 'structure-unit-size'
            --acumulated --by 'uid'

    The example output of the bars is as follows::

        \b
                                        <graph_title>
                                `
                                -                      ______    ````````
                                `                _____/          ` # \\  `
                                -               /          __    ` @  }->  <by>
                                `          ____/      ____/      ` & /  `
                <func>(<of>)    -      ___/       ___/           ````````
                                `  ___/    ______/       ____
                                -/  ______/        _____/
                                `__/______________/
                                +````||````||````||````||````

                                          <through>

    Refer to :ref:`views-flow` for more thorough description and example of
    `flow` interpretation possibilities.
    """
    if use_terminal:
        heap_map = convert.to_heap_map_format(profile)
        curses_graphs.flow_graph(heap_map)
    else:
        try:
            bokeh_helpers.process_profile_to_graphs(flow_factory, profile,
                                                    filename, view_in_browser,
                                                    **kwargs)
        except AttributeError as attr_error:
            log.error("while creating flow graph: {}".format(str(attr_error)))
        except InvalidParameterException as ip_error:
            log.error(str(ip_error))