def main(): args = Args() args.parse() hists = [] for file_name in args.i_file_names: h = Hist() h.load(file_name) hists.append(Cdf(h.dict)) plot(hists, args.o_file_name)
def share_hist(hist1, cpi1, cpi2, inst_mix1, inst_mix2): dict_ = {} for rdist1, count1 in hist1: cycles = (rdist1 * cpi1) / inst_mix1 rdist2 = (cycles / cpi2) * inst_mix2 dict_[my_round(rdist1 + rdist2)] = count1 return Hist(dict_)
def parse_usf(usf_file): dict_ = {} for event in usf_file: if event.type == pyusf.USF_EVENT_SAMPLE: rdist = event.end.time - event.begin.time - 1 elif event.type == pyusf.USF_EVENT_DANGLING: rdist = sys.maxint else: continue if dict_.has_key(rdist): dict_[rdist] += 1 else: dict_[rdist] = 1 return Hist(dict_)
def __init__(self, dict_): _Hist.__init__(self, dict_)
def read_hist(file_name1, file_name2, file_type): if file_type == "usf": try: usf_file1 = pyusf.Usf(file_name1) usf_file2 = pyusf.Usf(file_name2) except IOError, e: print_and_exit(str(e)) hist1 = parse_usf(usf_file1) hist2 = parse_usf(usf_file2) usf_file1.close() usf_file2.close() elif file_type == "hist": hist1 = Hist() hist2 = Hist() hist1.load(file_name1) hist2.load(file_name2) else: print_and_exit("XXX") return hist1, hist2 def main(): args = Args() args.parse() hist1, hist2 = read_hist(args.i_file_name1, args.i_file_name2, args.file_type)