Ejemplo n.º 1
0
    def test5_bReader(self):
        reader = binaryReader("{}/trace.vscsi".format(DAT_FOLDER),
                              init_params={"label":6, "real_time":7, "fmt": "<3I2H2Q"})

        cH = cHeatmap()
        bpr = cH.get_breakpoints(reader, 'r', time_interval=1000000)
        self.assertEqual(bpr[10], 53)
        bpv = cH.get_breakpoints(reader, 'v', time_interval=1000)
        self.assertEqual(bpv[10], 10000)

        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_pixels=100, num_of_threads=4, cache_size=2000)
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_threads=4, cache_size=2000)
        cH.heatmap(reader, 'r', "rd_distribution",
                   num_of_pixels=1000, num_of_threads=4)
        cH.heatmap(reader, 'r', "future_rd_distribution",
                   num_of_pixels=1000, num_of_threads=4)
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_pixels=100, algorithm="FIFO",
                   num_of_threads=4, cache_size=200)

        cH.diffHeatmap(reader, 'r', "hit_ratio_start_time_end_time",
                       num_of_pixels=24, cache_size=200,
                       algorithm1="LRU", algorithm2="Optimal",
                       cache_params2=None, num_of_threads=4)
Ejemplo n.º 2
0
def cold_miss_ratio_2d(reader,
                       mode,
                       time_interval,
                       figname="cold_miss_ratio2d.png",
                       **kwargs):
    """
    plot the percent of cold miss per time_interval
    :param reader:
    :param mode: either 'r' or 'v' for real time(wall-clock time) or virtual time(reference time)
    :param time_interval:
    :param figname:
    :return: the list of data points
    """

    kwargs_plot = {}
    kwargs_plot.update(kwargs)

    kwargs_plot["xlabel"] = kwargs_plot.get(
        "xlabel", '{} Time'.format("Real" if mode == "r" else "Virtual"))
    kwargs_plot["ylabel"] = kwargs_plot.get(
        "ylabel", 'Cold Miss Ratio (interval={})'.format(time_interval))
    kwargs_plot["title"] = kwargs_plot.get("title", 'Cold Miss Ratio 2D plot')
    kwargs_plot["xticks"] = kwargs_plot.get(
        "xticks",
        ticker.FuncFormatter(
            lambda x, pos: '{:2.0f}%'.format(x * 100 / len(break_points))))

    assert mode == 'r' or mode == 'v', "currently only support mode r and v, unknown mode {}".format(
        mode)
    break_points = cHeatmap().get_breakpoints(reader, mode, time_interval)

    cold_miss_list = [0] * (len(break_points) - 1)
    seen_set = set()
    for i in range(len(break_points) - 1):
        never_see = 0
        for j in range(break_points[i + 1] - break_points[i]):
            r = next(reader)
            if r not in seen_set:
                seen_set.add(r)
                never_see += 1
        cold_miss_list[i] = never_see / (break_points[i + 1] - break_points[i])

    draw2d(cold_miss_list, figname=figname, **kwargs_plot)
    reader.reset()
    return cold_miss_list
Ejemplo n.º 3
0
    def test2_pReader(self):
        reader = plainReader("{}/trace.txt".format(DAT_FOLDER))
        cH = cHeatmap()
        bpv = cH.get_breakpoints(reader, 'v', time_interval=1000)
        self.assertEqual(bpv[10], 10000)

        cH.heatmap(reader, 'v', "hit_ratio_start_time_end_time",
                   time_interval=1000, num_of_threads=4, cache_size=2000)
        cH.heatmap(reader, 'v', "rd_distribution",
                   time_interval=1000, num_of_threads=4)
        cH.heatmap(reader, 'v', "future_rd_distribution",
                   time_interval=1000, num_of_threads=4)
        cH.heatmap(reader, 'v', "hit_ratio_start_time_end_time",
                   time_interval=10000, algorithm="FIFO",
                   num_of_threads=4, cache_size=2000)

        cH.diffHeatmap(reader, 'v', "hit_ratio_start_time_end_time",
                       time_interval=10000, cache_size=200,
                       algorithm1="LFU", algorithm2="Optimal",
                       cache_params2=None, num_of_threads=4)
Ejemplo n.º 4
0
    def test4_cReader_r(self):
        reader = csvReader("{}/trace.csv".format(DAT_FOLDER),
                           init_params={"header":True, "label":5, 'real_time':2})
        cH = cHeatmap()
        bpr = cH.get_breakpoints(reader, 'r', time_interval=1000000)
        self.assertEqual(bpr[10], 53)

        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_pixels=24, num_of_threads=4, cache_size=2000)
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_threads=4, cache_size=2000)
        cH.heatmap(reader, 'r', "rd_distribution",
                   num_of_pixels=1000, num_of_threads=4)
        cH.heatmap(reader, 'r', "future_rd_distribution",
                   num_of_pixels=1000, num_of_threads=4)
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_pixels=100, algorithm="FIFO",
                   num_of_threads=4, cache_size=2000)

        cH.diffHeatmap(reader, 'r', "hit_ratio_start_time_end_time",
                       time_interval=100000000, cache_size=200,
                       algorithm1="LFUFast", algorithm2="Optimal",
                       cache_params2=None, num_of_threads=4)
Ejemplo n.º 5
0
    def test1_vReader(self):
        reader = vscsiReader("{}/trace.vscsi".format(DAT_FOLDER))
        cH = cHeatmap()
        bpr = cH.get_breakpoints(reader, 'r', time_interval=1000000)
        self.assertEqual(bpr[10], 53)
        bpr = cH.get_breakpoints(reader, 'r', num_of_pixels=1000)
        # print(bpr)
        bpv = cH.get_breakpoints(reader, 'v', time_interval=1000)
        self.assertEqual(bpv[10], 10000)

        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   time_interval=10000000, num_of_threads=4, cache_size=200)
        cH.heatmap(reader, 'r', "rd_distribution",
                   time_interval=10000000, num_of_threads=4)
        cH.heatmap(reader, 'r', "future_rd_distribution",
                   time_interval=10000000, num_of_threads=4)
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   time_interval=10000000, algorithm="FIFO",
                   num_of_threads=4, cache_size=2000)
        cH.diffHeatmap(reader, 'r', "hit_ratio_start_time_end_time",
                       cache_size=200, time_interval=100000000,
                       algorithm1="LRU", algorithm2="Optimal",
                       cache_params2=None, num_of_threads=4)
Ejemplo n.º 6
0
def request_rate_2d(reader,
                    mode,
                    time_interval,
                    figname="request_rate.png",
                    **kwargs):
    """
    plot the number of requests per time_interval vs time
    :param reader:
    :param mode: either 'r' or 'v' for real time(wall-clock time) or virtual time(reference time)
    :param time_interval:
    :param figname:
    :return: the list of data points
    """

    kwargs_plot = {}
    kwargs_plot.update(kwargs)

    kwargs_plot["xlabel"] = kwargs_plot.get(
        "xlabel", '{} Time'.format("Real" if mode == "r" else "Virtual"))
    kwargs_plot["ylabel"] = kwargs_plot.get(
        "ylabel", 'Request Rate (interval={})'.format(time_interval))
    kwargs_plot["title"] = kwargs_plot.get("title", 'Request Rate Plot')
    kwargs_plot["xticks"] = kwargs_plot.get(
        "xticks",
        ticker.FuncFormatter(
            lambda x, pos: '{:2.0f}%'.format(x * 100 / len(break_points))))

    assert mode == 'r' or mode == 'v', "currently only support mode r and v, what mode are you using?"
    break_points = cHeatmap().get_breakpoints(reader, mode, time_interval)

    l = []
    for i in range(1, len(break_points)):
        l.append(break_points[i] - break_points[i - 1])

    draw2d(l, figname=figname, **kwargs_plot)
    return l