def __init__(self, hist_file_name1, hist_file_name2, mix1, mix2, cpi_func1 = None, cpi_func2 = None): self.mix1 = mix1 self.mix2 = mix2 self.hist1 = load_hist(hist_file_name1) self.hist2 = load_hist(hist_file_name2) self.esd1 = LinearInterp(lrumodel.lru_sdist(self.hist1, True).items()) self.esd2 = LinearInterp(lrumodel.lru_sdist(self.hist2, True).items()) self.n1 = float(sum(self.hist1.values())) self.n2 = float(sum(self.hist2.values())) self.n = self.n1 + self.n2 default_cpi_func = lambda mr, mix: 1.0 + 300.0 * mix * mr if cpi_func1: self.cpi_func1 = cpi_func1 else: self.cpi_func1 = default_cpi_func if cpi_func2: self.cpi_func2 = cpi_func2 else: self.cpi_func2 = default_cpi_func
def __init__(self, hist_file_name1, hist_file_name2, mix1, mix2, cpi_func1=None, cpi_func2=None): self.mix1 = mix1 self.mix2 = mix2 self.hist1 = load_hist(hist_file_name1) self.hist2 = load_hist(hist_file_name2) self.esd1 = LinearInterp(lrumodel.lru_sdist(self.hist1, True).items()) self.esd2 = LinearInterp(lrumodel.lru_sdist(self.hist2, True).items()) self.n1 = float(sum(self.hist1.values())) self.n2 = float(sum(self.hist2.values())) self.n = self.n1 + self.n2 default_cpi_func = lambda mr, mix: 1.0 + 300.0 * mix * mr if cpi_func1: self.cpi_func1 = cpi_func1 else: self.cpi_func1 = default_cpi_func if cpi_func2: self.cpi_func2 = cpi_func2 else: self.cpi_func2 = default_cpi_func
def generate_per_pc_sdist_recurrence_hist(burst_hists): pc_sdist_hist = {} pc_recur_hist = {} pc_fwd_sdist_hist = {} for (pc_rdist_hist, pc_freq_hist, pc_corr_hist, pc_fwd_rdist_hist) in burst_hists: rdist_hist = rdist_hist_original(burst_hists) r2s = lrumodel.lru_sdist(rdist_hist) for (pc, rdist_hist) in pc_rdist_hist.items(): if not pc in pc_sdist_hist: pc_sdist_hist[pc] = {} for (rdist, count) in rdist_hist.items(): sd = int(round(r2s[rdist])) pc_sdist_hist[pc][sd] = pc_sdist_hist[pc].get(sd, 0) + count for (pc, fwd_rdist_hist) in pc_fwd_rdist_hist.items(): if not pc in pc_fwd_sdist_hist: pc_fwd_sdist_hist[pc] = {} for (rdist, count) in fwd_rdist_hist.items(): sd = int(round(r2s[rdist])) pc_fwd_sdist_hist[pc][sd] = pc_fwd_sdist_hist[pc].get(sd, 0) + count return [pc_sdist_hist, pc_fwd_sdist_hist]
def generate_sdist_hist(rdist_hist): hist = {} r2s = lrumodel.lru_sdist(rdist_hist) for (rdist, count) in rdist_hist.items(): sdist = r2s[rdist] hist[sdist] = hist.get(sdist, 0) + count return hist
def generate_sdist_hist(burst_hists): hist = {} for (rdists, filtered_rdists) in burst_hists: r2s = lrumodel.lru_sdist(rdists) for (rdist, count) in filtered_rdists.items(): sdist = r2s[rdist] hist[sdist] = hist.get(sdist, 0) + count return hist
def rdist2sdist_usf(usf_event_list): rdist_hist = {} for event in usf_event_list: if isinstance(event, pyusf.Sample): rdist = event.end.time - event.begin.time - 1 elif isinstance(event, pyusf.Dangling): rdist = sys.maxint if rdist_hist.has_key(rdist): rdist_hist[rdist] += 1 else: rdist_hist[rdist] = rdist return lrumodel.lru_sdist(rdist_hist)
def generate_per_pc_sdist_recurrence_hist(burst_hists): pc_sdist_hist = {} pc_recur_hist = {} pc_fwd_sdist_hist = {} r2s = {} for (pc_rdist_hist, pc_stride_hist, pc_freq_hist, pc_time_hist, pc_corr_hist, pc_fwd_rdist_hist, pc_adjp1_cl_rdist_hist, pc_adjm1_cl_rdist_hist) in burst_hists: rdist_hist = rdist_hist_original(burst_hists) r2s = lrumodel.lru_sdist(rdist_hist) for (pc, rdist_hist) in pc_rdist_hist.items(): if not pc in pc_sdist_hist: pc_sdist_hist[pc] = {} for (rdist, count) in rdist_hist.items(): sd = int(round(r2s[rdist])) pc_sdist_hist[pc][sd] = pc_sdist_hist[pc].get(sd, 0) + count for (pc, fwd_rdist_hist) in pc_fwd_rdist_hist.items(): if not pc in pc_fwd_sdist_hist: pc_fwd_sdist_hist[pc] = {} for (rdist, count) in fwd_rdist_hist.items(): sd = int(round(r2s[rdist])) pc_fwd_sdist_hist[pc][sd] = pc_fwd_sdist_hist[pc].get(sd, 0) + count for (pc, time_hist) in pc_time_hist.items(): if not pc in pc_recur_hist: pc_recur_hist[pc] = {} for (recur, count) in time_hist.items(): if not recur in r2s: recur_c = min(r2s.keys(), key=lambda k: abs(k - recur)) recur = recur_c sd = int(round(r2s[recur])) pc_recur_hist[pc][sd] = pc_recur_hist[pc].get(sd, 0) + count return [pc_sdist_hist, pc_recur_hist, pc_fwd_sdist_hist, r2s]
def init(self, pcs, global_rdist_hist): self.r2s = lrumodel.lru_sdist(global_rdist_hist) nta.NTACondition.init(self, pcs, global_rdist_hist)