def miss_ratio(rdist_histograms, _type='rw', boundary=False): tmp_sdist_hist = sdist_hist(rdist_histograms, _type, boundary) rdist_histograms['sdist_hist'] = tmp_sdist_hist sdist_hist_items = tmp_sdist_hist.items() sdist_hist_items.sort(lambda (k0, v0), (k1, v1): cmp(k0, k1)) ref_count = sum(rdist_histograms['rw_rdist_hist'].values()) if _type == 'rw': pass elif _type == 'r': wr_count = sum(rdist_histograms['wr_rdist_hist'].values()) ref_count -= wr_count elif _type == 'w': rd_count = sum(rdist_histograms['rd_rdist_hist'].values()) ref_count -= rd_count else: raise Exception("Unknown sample type") miss_count = ref_count miss_ratio = [] if ref_count < 0: raise Exception("negative ref_count") elif ref_count == 0: return None, None for sdist, count in sdist_hist_items: miss_ratio.append((sdist, float(miss_count) / ref_count)) miss_count -= count return missratio.MissRatio(miss_ratio), ref_count
def miss_ratio_range(self, cache_size_range): sdist_hist = self.sdist_hist() mr = self.miss_ratio(sdist_hist) mr_out = [] for cache_size in cache_size_range: mr_out.append((cache_size, mr[cache_size])) return missratio.MissRatio(mr_out)
def miss_ratio_range(rdist_hist_list, cache_size_range, boundary=False, filtered_rdist_hist_list=None): mr = miss_ratio(rdist_hist_list, filtered_rdist_hist_list, boundary) mr_out = [] for cache_size in cache_size_range: mr_out.append((cache_size, mr[cache_size])) return missratio.MissRatio(mr_out)
def miss_ratio_range(rdist_histograms, cache_size_range, _type='rw', boundary=False): mr, ref_count = miss_ratio(rdist_histograms, _type, boundary) if mr is None: return None, None mr_out = [] for cache_size in cache_size_range: mr_out.append((cache_size, mr[cache_size])) return missratio.MissRatio(mr_out), ref_count
def miss_ratio(self, sdist_hist, global_ref=False): burst_info = self.burst_info[0] sdist_hist_items = sdist_hist.items() sdist_hist_items.sort(lambda (k0, v0), (k1, v1): cmp(k0, k1)) miss_count = sum(burst_info.frdist_hist.values()) ref_count = \ sum(burst_info.rdist_hist.values()) if global_ref else miss_count miss_ratio = [] for sdist, count in sdist_hist_items: miss_ratio.append((sdist, float(miss_count) / ref_count)) miss_count -= count return missratio.MissRatio(miss_ratio)
def miss_ratio(rdist_hist_list, filtered_rdist_hist_list, boundary=False): if filtered_rdist_hist_list == None: filtered_rdist_hist_list = rdist_hist_list sdist_hist_items = sdist_hist(rdist_hist_list, filtered_rdist_hist_list, boundary).items() sdist_hist_items.sort(lambda (k0, v0), (k1, v1): cmp(k0, k1)) ref_count = reduce(lambda y, x: y + sum(x.values()), filtered_rdist_hist_list, 0) miss_count = ref_count miss_ratio = [] for sdist, count in sdist_hist_items: miss_ratio.append((sdist, float(miss_count) / ref_count)) miss_count -= count return missratio.MissRatio(miss_ratio)
def miss_ratio_range(rdist_hist_list, cache_size_range, filtered_rdist_hist_list = None): if filtered_rdist_hist_list == None: filtered_rdist_hist_list = rdist_hist_list if len(rdist_hist_list) > 1: print >> sys.stderr, "Warning: Random analysis will only be " + \ "performed for the last burst." mr = [] for cache_size in cache_size_range: mr.append((cache_size, miss_ratio(rdist_hist_list[-1], filtered_rdist_hist_list[-1], cache_size))) return missratio.MissRatio(mr)