def heatmap(self, time_mode, plot_type, time_interval=-1, num_of_pixels=-1, algorithm="LRU", cache_params=None, cache_size=-1, **kwargs): """ plot heatmaps, currently supports the following heatmaps * hit_ratio_start_time_end_time * hit_ratio_start_time_cache_size (python only) * avg_rd_start_time_end_time (python only) * cold_miss_count_start_time_end_time (python only) * rd_distribution * rd_distribution_CDF * future_rd_distribution * dist_distribution * reuse_time_distribution :param time_mode: the type of time, can be "v" for virtual time, or "r" for real time :param plot_type: the name of plot types, see above for plot types :param time_interval: the time interval of one pixel :param num_of_pixels: if you don't to use time_interval, you can also specify how many pixels you want in one dimension, note this feature is not well tested :param algorithm: what algorithm to use for plotting heatmap, this is not required for distance related heatmap like rd_distribution :param cache_params: parameters passed to cache, some of the cache replacement algorithms require parameters, for example LRU-K, SLRU :param cache_size: The size of cache, this is required only for *hit_ratio_start_time_end_time* :param kwargs: other parameters for computation and plotting such as num_of_threads, figname """ assert self.reader is not None, "you haven't opened a trace yet" assert cache_size <= self.num_of_req(), \ "you cannot specify cache size({}) larger than " \ "trace length({})".format(cache_size, self.num_of_req()) if algorithm.lower() in C_AVAIL_CACHE: hm = CHeatmap() else: hm = PyHeatmap() hm.heatmap(self.reader, time_mode, plot_type, time_interval=time_interval, num_of_pixels=num_of_pixels, cache_size=cache_size, algorithm=CACHE_NAME_CONVRETER[algorithm.lower()], cache_params=cache_params, **kwargs)
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
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
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
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
def diff_heatmap(self, time_mode, plot_type, algorithm1="LRU", time_interval=-1, num_of_pixels=-1, algorithm2="Optimal", cache_params1=None, cache_params2=None, cache_size=-1, **kwargs): """ Plot the differential heatmap between two algorithms by alg2 - alg1 :param cache_size: size of cache :param time_mode: time time_mode "v" for virutal time, "r" for real time :param plot_type: same as the name in heatmap function :param algorithm1: name of the first alg :param time_interval: same as in heatmap :param num_of_pixels: same as in heatmap :param algorithm2: name of the second algorithm :param cache_params1: parameters of the first algorithm :param cache_params2: parameters of the second algorithm :param kwargs: include num_of_threads """ figname = kwargs.get("figname", 'differential_heatmap.png') num_of_threads = kwargs.get("num_of_threads", DEF_NUM_THREADS) assert self.reader is not None, "you haven't opened a trace yet" assert cache_size != -1, "you didn't provide size for cache" assert cache_size <= self.num_of_req(), \ "you cannot specify cache size({}) larger than " \ "trace length({})".format(cache_size, self.num_of_req()) if algorithm1.lower() in C_AVAIL_CACHE and algorithm2.lower() in C_AVAIL_CACHE: hm = CHeatmap() hm.diff_heatmap(self.reader, time_mode, plot_type, cache_size=cache_size, time_interval=time_interval, num_of_pixels=num_of_pixels, algorithm1=CACHE_NAME_CONVRETER[algorithm1.lower()], algorithm2=CACHE_NAME_CONVRETER[algorithm2.lower()], cache_params1=cache_params1, cache_params2=cache_params2, **kwargs) else: hm = PyHeatmap() if algorithm1.lower() not in C_AVAIL_CACHE: xydict1 = hm.compute_heatmap(self.reader, time_mode, plot_type, time_interval=time_interval, cache_size=cache_size, algorithm=algorithm1, cache_params=cache_params1, **kwargs)[0] else: xydict1 = c_heatmap.heatmap(self.reader.c_reader, time_mode, plot_type, cache_size=cache_size, time_interval=time_interval, algorithm=algorithm1, cache_params=cache_params1, num_of_threads=num_of_threads) if algorithm2.lower() not in C_AVAIL_CACHE: xydict2 = hm.compute_heatmap(self.reader, time_mode, plot_type, time_interval=time_interval, cache_size=cache_size, algorithm=algorithm2, cache_params=cache_params2, **kwargs)[0] else: xydict2 = c_heatmap.heatmap(self.reader.c_reader, time_mode, plot_type, time_interval=time_interval, cache_size=cache_size, algorithm=algorithm2, cache_params=cache_params2, num_of_threads=num_of_threads) text = "differential heatmap\ncache size: {},\ncache type: ({}-{})/{},\n" \ "time type: {},\ntime interval: {},\nplot type: \n{}".format( cache_size, algorithm2, algorithm1, algorithm1, time_mode, time_interval, plot_type) x1, y1 = xydict1.shape x1, y1 = int(x1 / 2.8), y1/8 ax = plt.gca() ax.text(x1, y1, text) np.seterr(divide='ignore', invalid='ignore') plot_data = (xydict2 - xydict1) / xydict1 plot_data = np.ma.array(plot_data, mask=np.tri(len(plot_data), k=-1, dtype=int).T) plot_kwargs = {"figname": figname} plot_kwargs["xlabel"] = plot_kwargs.get("xlabel", 'Start Time ({})'.format(time_mode)) plot_kwargs["xticks"] = plot_kwargs.get("xticks", ticker.FuncFormatter(lambda x, _: '{:.0%}'.format(x / (plot_data.shape[1]-1)))) plot_kwargs["ylabel"] = plot_kwargs.get("ylabel", "End Time ({})".format(time_mode)) plot_kwargs["yticks"] = plot_kwargs.get("yticks", ticker.FuncFormatter(lambda x, _: '{:.0%}'.format(x / (plot_data.shape[0]-1)))) plot_kwargs["imshow_kwargs"] = {"vmin": -1, "vmax": 1} draw_heatmap(plot_data, **plot_kwargs)
def diff_heatmap(self, time_mode, plot_type, algorithm1, time_interval=-1, num_of_pixels=-1, algorithm2="Optimal", cache_params1=None, cache_params2=None, cache_size=-1, **kwargs): """ Plot the differential heatmap between two algorithms by alg2 - alg1 :param cache_size: size of cache :param time_mode: time time_mode "v" for virutal time, "r" for real time :param plot_type: same as the name in heatmap function :param algorithm1: name of the first alg :param time_interval: same as in heatmap :param num_of_pixels: same as in heatmap :param algorithm2: name of the second algorithm :param cache_params1: parameters of the first algorithm :param cache_params2: parameters of the second algorithm :param kwargs: include num_of_threads """ figname = kwargs.get("figname", 'differential_heatmap.png') num_of_threads = kwargs.get("num_of_threads", DEF_NUM_THREADS) assert self.reader is not None, "you haven't opened a trace yet" assert cache_size != -1, "you didn't provide size for cache" assert cache_size <= self.num_of_req(), \ "you cannot specify cache size({}) larger than " \ "trace length({})".format(cache_size, self.num_of_req()) if algorithm1.lower() in C_AVAIL_CACHE and algorithm2.lower( ) in C_AVAIL_CACHE: hm = CHeatmap() hm.diff_heatmap( self.reader, time_mode, plot_type, cache_size=cache_size, time_interval=time_interval, num_of_pixels=num_of_pixels, algorithm1=CACHE_NAME_CONVRETER[algorithm1.lower()], algorithm2=CACHE_NAME_CONVRETER[algorithm2.lower()], cache_params1=cache_params1, cache_params2=cache_params2, **kwargs) else: hm = PyHeatmap() if algorithm1.lower() not in C_AVAIL_CACHE: xydict1 = hm.calculate_heatmap_dat(self.reader, time_mode, plot_type, time_interval=time_interval, cache_size=cache_size, algorithm=algorithm1, cache_params=cache_params1, **kwargs)[0] else: xydict1 = c_heatmap.heatmap(self.reader.c_reader, time_mode, plot_type, cache_size=cache_size, time_interval=time_interval, algorithm=algorithm1, cache_params=cache_params1, num_of_threads=num_of_threads) if algorithm2.lower() not in C_AVAIL_CACHE: xydict2 = hm.calculate_heatmap_dat(self.reader, time_mode, plot_type, time_interval=time_interval, cache_size=cache_size, algorithm=algorithm2, cache_params=cache_params2, **kwargs)[0] else: xydict2 = c_heatmap.heatmap(self.reader.c_reader, time_mode, plot_type, time_interval=time_interval, cache_size=cache_size, algorithm=algorithm2, cache_params=cache_params2, num_of_threads=num_of_threads) cHm = CHeatmap() text = " differential heatmap\n cache size: {},\n cache type: ({}-{})/{},\n" \ " time type: {},\n time interval: {},\n plot type: \n{}".format( cache_size, algorithm2, algorithm1, algorithm1, time_mode, time_interval, plot_type) x1, y1 = xydict1.shape x1 = int(x1 / 2.8) y1 /= 8 if time_mode == 'r': time_mode_string = "Real" elif time_mode == "v": time_mode_string = "Virtual" else: raise RuntimeError( "unknown time time_mode {}".format(time_mode)) cHm.set_plot_params( 'x', '{} Time'.format(time_mode_string), xydict=xydict1, label='Start Time ({})'.format(time_mode_string), text=(x1, y1, text)) cHm.set_plot_params('y', '{} Time'.format(time_mode_string), xydict=xydict1, label='End Time ({})'.format(time_mode_string), fixed_range=(-1, 1)) np.seterr(divide='ignore', invalid='ignore') plot_dict = (xydict2 - xydict1) / xydict1 cHm.draw_heatmap(plot_dict, figname=figname)
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")
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_interval_size", time_interval=10000000, num_of_threads=os.cpu_count(), cache_size=200, figname="vReader_hr_interval_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")
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())
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())
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())
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())
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")
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())
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())