Пример #1
0
    def test1_vReader(self):
        print("test1 vReader")
        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_pixel_of_time_dim=1000)
        bpv = cH.get_breakpoints(reader, 'v', time_interval=1000)
        self.assertEqual(bpv[10], 10000)

        cH.heatmap(reader, 'r', "hr_st_et",
                   time_interval=10000000, num_of_threads=os.cpu_count(),
                   cache_size=200, figname="vReader_hr_st_et_LRU.png")
        cH.heatmap(reader, 'r', "hr_st_size",
                   enable_ihr=True,
                   time_interval=10000000, num_of_threads=os.cpu_count(),
                   cache_size=200, figname="vReader_ihr_st_size.png")

        cH.heatmap(reader, 'r', "rd_distribution",
                   time_interval=10000000, num_of_threads=os.cpu_count(),
                   figname="vReader_rd_dist.png")
        cH.heatmap(reader, 'r', "future_rd_distribution",
                   time_interval=10000000, num_of_threads=os.cpu_count(),
                   figname="vReader_frd_dist.png")
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   time_interval=10000000, algorithm="FIFO",
                   num_of_threads=os.cpu_count(), cache_size=2000,
                   figname="vReader_hr_st_et_FIFO.png")
        cH.diff_heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                        cache_size=200, time_interval=100000000,
                        algorithm1="LRU", algorithm2="Optimal",
                        cache_params2=None, num_of_threads=os.cpu_count(),
                        figname="vReader_diff_hr_st_et.png")
Пример #2
0
    def test5_bReader(self):
        print("bReader")
        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_pixel_of_time_dim=100, num_of_threads=os.cpu_count(), cache_size=2000,
                   figname="hr_st_et_LRU_bReader.png")

        cH.heatmap(reader, 'r', "rd_distribution",
                   num_of_pixel_of_time_dim=1000, num_of_threads=os.cpu_count())
        cH.heatmap(reader, 'r', "future_rd_distribution",
                   num_of_pixel_of_time_dim=1000, num_of_threads=os.cpu_count())
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_pixel_of_time_dim=100, algorithm="FIFO",
                   num_of_threads=os.cpu_count(), cache_size=200)

        cH.diff_heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                        num_of_pixel_of_time_dim=24, cache_size=200,
                        algorithm1="LRU", algorithm2="Optimal",
                        cache_params2=None, num_of_threads=os.cpu_count())
Пример #3
0
def request_rate_2d(reader, time_mode, time_interval,
                    figname="request_rate.png", **kwargs):
    """
    plot the number of requests per time_interval vs time
    :param reader:
    :param time_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 time_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 time_mode == 'r' or time_mode == 'v', "currently only support time_mode r and v, what time_mode are you using?"
    break_points = Heatmap.get_breakpoints(reader, time_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
Пример #4
0
    def test2_pReader(self):
        print("test2 pReader r")
        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=os.cpu_count(), cache_size=2000,
                   figname="pReader_hr_st_et_LRU.png")
        cH.heatmap(reader, 'v', "rd_distribution",
                   time_interval=1000, num_of_threads=os.cpu_count(),
                   figname="pReader_rd_dist.png")
        cH.heatmap(reader, 'v', "future_rd_distribution",
                   time_interval=1000, num_of_threads=os.cpu_count(),
                   figname="pReader_frd_dist.png")
        cH.heatmap(reader, 'v', "hit_ratio_start_time_end_time",
                   time_interval=10000, algorithm="FIFO",
                   num_of_threads=os.cpu_count(), cache_size=2000,
                   figname="pReader_hr_st_et_FIFO.png")

        cH.diff_heatmap(reader, 'v', "hit_ratio_start_time_end_time",
                        time_interval=10000, cache_size=200,
                        algorithm1="LFU", algorithm2="Optimal",
                        cache_params2=None, num_of_threads=os.cpu_count(),
                        figname="pReader_diff_hr_st_et.png")
Пример #5
0
    def test3_c_reader_v(self):
        print("test3 c_reader v")
        reader = CsvReader("{}/trace.csv".format(DAT_FOLDER),
                           init_params={
                               "header": True,
                               "label": 5
                           })
        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",
        #            num_of_pixel_of_time_dim=24,
        #            num_of_threads=os.cpu_count(), cache_size=2000,
        #            figname="hr_st_et_LRU_c_reader_v.png")

        cH.heatmap(reader,
                   'v',
                   "rd_distribution",
                   num_of_pixel_of_time_dim=200,
                   num_of_threads=os.cpu_count(),
                   figname="c_reader_rd_dist.png")

        cH.heatmap(reader,
                   'v',
                   "rd_distribution_CDF",
                   num_of_pixel_of_time_dim=1000,
                   num_of_threads=os.cpu_count(),
                   figname="c_reader_rd_CDF_dist.png")

        cH.heatmap(reader,
                   'v',
                   "future_rd_distribution",
                   num_of_pixel_of_time_dim=1000,
                   num_of_threads=os.cpu_count(),
                   figname="c_reader_frd_dist.png")

        cH.heatmap(reader,
                   'v',
                   "hit_ratio_start_time_end_time",
                   num_of_pixel_of_time_dim=24,
                   algorithm="FIFO",
                   num_of_threads=os.cpu_count(),
                   cache_size=2000,
                   figname="c_reader_hr_st_et_FIFO.png")

        cH.diff_heatmap(reader,
                        'v',
                        "hit_ratio_start_time_end_time",
                        time_interval=10000,
                        cache_size=200,
                        algorithm1="SLRU",
                        algorithm2="Optimal",
                        cache_params2=None,
                        num_of_threads=os.cpu_count())
Пример #6
0
    def test4_c_reader_r(self):
        print("test4 c_reader r")
        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_pixel_of_time_dim=24,
                   num_of_threads=os.cpu_count(),
                   cache_size=2000,
                   figname="hr_st_et_LRU_c_reader_r.png")

        cH.heatmap(reader,
                   'r',
                   "rd_distribution",
                   num_of_pixel_of_time_dim=1000,
                   num_of_threads=os.cpu_count())
        cH.heatmap(reader,
                   'r',
                   "future_rd_distribution",
                   num_of_pixel_of_time_dim=1000,
                   num_of_threads=os.cpu_count())
        cH.heatmap(reader,
                   'r',
                   "hit_ratio_start_time_end_time",
                   num_of_pixel_of_time_dim=100,
                   algorithm="FIFO",
                   num_of_threads=os.cpu_count(),
                   cache_size=2000)

        cH.diff_heatmap(reader,
                        'r',
                        "hit_ratio_start_time_end_time",
                        time_interval=100000000,
                        cache_size=200,
                        algorithm1="LFUFast",
                        algorithm2="Optimal",
                        cache_params2=None,
                        num_of_threads=os.cpu_count())
Пример #7
0
def cold_miss_ratio_2d(reader,
                       time_mode,
                       time_interval,
                       figname="cold_miss_ratio2d.png",
                       **kwargs):
    """
    plot the percent of cold miss per time_interval
    :param reader:
    :param time_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 time_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 time_mode == 'r' or time_mode == 'v', "currently only support time_mode r and v, unknown time_mode {}".format(
        time_mode)
    break_points = Heatmap.get_breakpoints(reader, time_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
Пример #8
0
def cold_miss_count_2d(reader, time_mode, time_interval,
                       figname="cold_miss_count2d.png", **kwargs):
    """
    plot the number of cold miss per time_interval
    :param reader:
    :param time_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 time_mode == "r" else "Virtual"))
    kwargs_plot["ylabel"] = kwargs_plot.get("ylabel", 'Cold Miss Count (interval={})'.format(time_interval))
    kwargs_plot["title"] = kwargs_plot.get("title", 'Cold Miss Count 2D plot')
    kwargs_plot["xticks"] = kwargs_plot.get("xticks",
                        ticker.FuncFormatter(lambda x, pos: '{:2.0f}%'.format(x * 100 / len(break_points))))
    kwargs_plot["label"] = kwargs_plot.get("label", "Cold Miss Count")

    assert time_mode == 'r' or time_mode == 'v', "currently only support time_mode r and v, what time_mode are you using?"
    break_points = Heatmap.get_breakpoints(reader, time_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

    draw2d(cold_miss_list, figname=figname, **kwargs_plot)
    reader.reset()
    return cold_miss_list
Пример #9
0
    def test3_c_reader_v(self):
        print("test3 c_reader v")
        reader = CsvReader("{}/trace.csv".format(DAT_FOLDER),
                           init_params={"header":True, "label":5})
        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",
        #            num_of_pixel_of_time_dim=24,
        #            num_of_threads=os.cpu_count(), cache_size=2000,
        #            figname="hr_st_et_LRU_c_reader_v.png")

        cH.heatmap(reader, 'v', "rd_distribution",
                   num_of_pixel_of_time_dim=200,
                   num_of_threads=os.cpu_count(),
                   figname="c_reader_rd_dist.png")

        cH.heatmap(reader, 'v', "rd_distribution_CDF",
                   num_of_pixel_of_time_dim=1000,
                   num_of_threads=os.cpu_count(),
                   figname="c_reader_rd_CDF_dist.png")

        cH.heatmap(reader, 'v', "future_rd_distribution",
                   num_of_pixel_of_time_dim=1000,
                   num_of_threads=os.cpu_count(),
                   figname="c_reader_frd_dist.png")

        cH.heatmap(reader, 'v', "hit_ratio_start_time_end_time",
                   num_of_pixel_of_time_dim=24, algorithm="FIFO",
                   num_of_threads=os.cpu_count(), cache_size=2000,
                   figname="c_reader_hr_st_et_FIFO.png")

        cH.diff_heatmap(reader, 'v', "hit_ratio_start_time_end_time",
                        time_interval=10000, cache_size=200,
                        algorithm1="SLRU", algorithm2="Optimal",
                        cache_params2=None, num_of_threads=os.cpu_count())
Пример #10
0
    def test4_c_reader_r(self):
        print("test4 c_reader r")
        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_pixel_of_time_dim=24, num_of_threads=os.cpu_count(), cache_size=2000,
                   figname="hr_st_et_LRU_c_reader_r.png")

        cH.heatmap(reader, 'r', "rd_distribution",
                   num_of_pixel_of_time_dim=1000, num_of_threads=os.cpu_count())
        cH.heatmap(reader, 'r', "future_rd_distribution",
                   num_of_pixel_of_time_dim=1000, num_of_threads=os.cpu_count())
        cH.heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                   num_of_pixel_of_time_dim=100, algorithm="FIFO",
                   num_of_threads=os.cpu_count(), cache_size=2000)

        cH.diff_heatmap(reader, 'r', "hit_ratio_start_time_end_time",
                        time_interval=100000000, cache_size=200,
                        algorithm1="LFUFast", algorithm2="Optimal",
                        cache_params2=None, num_of_threads=os.cpu_count())
Пример #11
0
def request_rate_2d(reader,
                    time_mode,
                    time_interval,
                    figname="request_rate.png",
                    **kwargs):
    """
    plot the number of requests per time_interval vs time
    :param reader:
    :param time_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 time_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 time_mode == 'r' or time_mode == 'v', "currently only support time_mode r and v, what time_mode are you using?"
    break_points = Heatmap.get_breakpoints(reader, time_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