Esempio n. 1
0
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)
def test_heat_map(memory_profiles):
    """Test generation of the heat map information from the profile

    Expecting no errors and returned dictionary with the internal representation
    """
    for memory_profile in memory_profiles:
        heat_map = convert.to_heat_map_format(memory_profile)
        number_of_cells = (heat_map['stats']['max_address'] -
                           heat_map['stats']['min_address'])
        assert len(heat_map['map']) == number_of_cells
Esempio n. 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)
Esempio n. 4
0
def test_heat_map(mock_curses_window, monkeypatch, memory_profiles):
    """Test heap map without the logic and anything, hopefully will work

    Expecting no error and some layer of testing
    """
    monkeypatch.setattr(curses, 'curs_set', donothing)
    monkeypatch.setattr(curses, 'color_pair', returnnothing)

    for memory_profile in memory_profiles:
        heat_map_representation = convert.to_heat_map_format(memory_profile)
        hm_visualization = heap_map.HeapMapVisualization(
            mock_curses_window, heat_map_representation,
            heap_colours.HeapMapColors.NO_COLORS)
        hm_visualization.draw_heat_map()

        str_window = str(mock_curses_window)
        assert str(
            heat_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 'HEAT INFO' in str_window
        assert "Number of accesses" in str_window