def updateUberXMean(start_loc_id, end_loc_id, dayTimeInterval_id, uberXEntry): uberXMean_record = session.query(UberXMean).filter(UberXMean.day_time_interval_id==dayTimeInterval_id). \ filter(UberXMean.start_location_id==start_loc_id). \ filter(UberXMean.end_location_id==end_loc_id).first() if uberXMean_record == None: # No current Mean records exists for that timestamp and route new_uberX_mean = UberXMean(start_location_id=start_loc_id, end_location_id=end_loc_id, \ surge=uberXEntry['surge'], highEstimate=uberXEntry['highEstimate'], lowEstimate=uberXEntry['lowEstimate'], \ minimum=uberXEntry['minimum'], distance=uberXEntry['distance'], duration=uberXEntry['duration'], \ day_time_interval_id= dayTimeInterval_id, data_points=1 ) session.add(new_uberX_mean) session.commit() print 'Added New Record' else: # Update Surge uberXMean_record.surge = averageData(uberXMean_record.surge, uberXMean_record.data_points, uberXEntry['surge']) # Update highEstimate uberXMean_record.highEstimate = averageData(uberXMean_record.highEstimate, uberXMean_record.data_points, uberXEntry['highEstimate']) # Update lowEstimate uberXMean_record.lowEstimate = averageData(uberXMean_record.lowEstimate, uberXMean_record.data_points, uberXEntry['lowEstimate']) # Update Minimum uberXMean_record.minimum = averageData(uberXMean_record.minimum, uberXMean_record.data_points, uberXEntry['minimum']) # Update Distance uberXMean_record.distance = averageData(uberXMean_record.distance, uberXMean_record.data_points, uberXEntry['distance']) # Update Duration uberXMean_record.duration = averageData(uberXMean_record.duration, uberXMean_record.data_points, uberXEntry['duration']) # Update Data Points uberXMean_record.data_points = uberXMean_record.data_points + 1 session.commit() print 'Updated Record'
def __plotWorkDist(data, key, module="", ylogscale=False, ylabel="", yrange=None): # Programs Executed tmp = {} for name in data: __tmp = {} for job in ["Generate", "Mutate", "Triage"]: __tmp[job] = averageData(data[name], key="Time_Elapsed", value=key + "_" + job, bin_size=600) tmp[name + "_" + job] = __tmp[job] plot(__tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel=ylabel, outfile="work_%s_%s_%s.png" % (module, key, name), ylogscale=ylogscale, xunit=3600.0, nmarkers=13, xstep=4) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel=ylabel, outfile="work_%s_%s.png" % (module, key), ylogscale=ylogscale, xunit=3600.0, nmarkers=13, xstep=4) tmp = {} for name in data: tmp[name] = {} for job in ["Generate", "Mutate", "Triage"]: tmp[name][job] = [] for d in data[name]: tmp[name][job].append(d[-1][key + "_" + job]) plotBar1(tmp, ylabel=ylabel, outfile="work_%s_%s_bar.png" % (module, key), ylogscale=ylogscale, yrange=yrange)
def initUberXMeanTable(startLoc, endLoc): start_location = session.query(Locations).filter(Locations.name == startLoc).one() end_location = session.query(Locations).filter(Locations.name == endLoc).one() uberX_records = session.query(UberXData).filter(UberXData.start_location_id==start_location.id). \ filter(UberXData.end_location_id==end_location.id) for uberXEntry in uberX_records: time_interval = uberXEntry.timestamp_interval_EST weekday_index = time_interval.weekday() time = time_interval.time() dayTimeInterval_record = session.query(DayTimeIntervals).filter(DayTimeIntervals.day_index==weekday_index). \ filter(DayTimeIntervals.time_interval==time).first() uberXMean_record = session.query(UberXMean).filter(UberXMean.day_time_interval_id==dayTimeInterval_record.id). \ filter(UberXMean.start_location_id==start_location.id). \ filter(UberXMean.end_location_id==end_location.id).first() if uberXMean_record == None: # No current Mean records exists for that timestamp and route new_uberX_mean = UberXMean(start_location_id=start_location.id, end_location_id=end_location.id, \ surge=uberXEntry.surge, highEstimate=uberXEntry.highEstimate, lowEstimate=uberXEntry.lowEstimate, \ minimum=uberXEntry.minimum, distance=uberXEntry.distance, duration=uberXEntry.duration, \ day_time_interval_id= dayTimeInterval_record.id, data_points=1 ) session.add(new_uberX_mean) session.commit() print 'Added New Record' else: # Update Surge uberXMean_record.surge = averageData(uberXMean_record.surge, uberXMean_record.data_points, uberXEntry.surge) # Update highEstimate uberXMean_record.highEstimate = averageData(uberXMean_record.highEstimate, uberXMean_record.data_points, uberXEntry.highEstimate) # Update lowEstimate uberXMean_record.lowEstimate = averageData(uberXMean_record.lowEstimate, uberXMean_record.data_points, uberXEntry.lowEstimate) # Update Minimum uberXMean_record.minimum = averageData(uberXMean_record.minimum, uberXMean_record.data_points, uberXEntry.minimum) # Update Distance uberXMean_record.distance = averageData(uberXMean_record.distance, uberXMean_record.data_points, uberXEntry.distance) # Update Duration uberXMean_record.duration = averageData(uberXMean_record.duration, uberXMean_record.data_points, uberXEntry.duration) # Update Data Points uberXMean_record.data_points = uberXMean_record.data_points + 1 session.commit() print 'Updated Record'
def plotMAB(tests=["RAMINDEX", "KCOV"]): data = {} weight = {} # Determine whether we should split by module splitByModule = False for test in tests: print(test) #if not "MAB" in test: # continue try: __data, GLC = loadDataCached('mab_%s.cache', test, __processTest); print(test, len(__data), __data[-1] if len(__data) > 0 else -1) print(GLC[0][-1], GLC[1][-1], GLC[2][-1]) name, module, run = getTestParams(test) print(name, module, run) if not module in data: data[module] = {} if not name in data[module]: data[module][name] = [] data[module][name].append(__data); # Pring GLC CDF ''' label = ["Gain", "Loss", "Cost", "NormGain", "NormLoss", "NormCost"] for i in range(6): cdf_data = { "Generate": [v[i] for v in GLC[0]], "Mutate": [v[i] for v in GLC[1]], "Triage": [v[i] for v in GLC[2]], } plotCDF(cdf_data, xlabel=label[i], outfile="mab_%s_cdf_%s.png" % (label[i].lower(), test)) ''' except: traceback.print_exc(); pass; for module in data: tmp = {} keys = ["MABOverhead", "MABSync", "MABDequeue", "MABPoll", "MABUpdate"] for k in keys: for name in data[module]: tmp[name] = averageData(data[module][name], key="ts", value=k, median=False) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel=k, outfile="mab_%s_%s.png" % (module, k), xunit=3600.0, xstep=4); # Per module overhead for name in data[module]: tmp = {"Sync": [], "Update": []} tmp["Sync"] = averageData(data[module][name], key="ts", value="MABSync", median=False) tmp["Update"] = averageData(data[module][name], key="ts", value="MABUpdate", median=False) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Overhead (min)", outfile="mab_%s_%s.png" % (module, name), xunit=3600.0, yunit=60.0, xstep=4); # MAB Prob mab_prob_tri = {} mab_prob_mg = {} for name in data[module]: if not "TS" in name: continue # Probability mab_prob = {"Generate": [], "Mutate": [], "Triage": []} mab_prob_tri[name] = [] mab_prob_mg[name] = [] tri = [] mg = [] prob = [[], [], []] for i in range(len(data[module][name])): d = data[module][name][i] for v in d: ts = v["ts"] prob[0].append((ts, v["MABProbability"][0])) prob[1].append((ts, v["MABProbability"][1])) prob[2].append((ts, v["MABProbability"][2])) if v["MABProbability"][2] > 0: tri.append((ts, v["MABProbability"][2])) if v["MABProbability"][0] > 0 and v["MABProbability"][1] > 0: mg.append((ts, math.log(v["MABProbability"][1] / v["MABProbability"][0], 10))) mab_prob["Generate"].append(prob[0]) mab_prob["Mutate"].append(prob[1]) mab_prob["Triage"].append(prob[2]) mab_prob_tri[name].append(tri) print(tri[-1]) mab_prob_mg[name].append(mg) for arm in mab_prob: mab_prob[arm] = averageData(mab_prob[arm], key=0, value=1, bin_size=1800.0, bin_avg=True, median=False) mab_prob_mg[name] = averageData(mab_prob_mg[name], key=0, value=1, bin_size=1800.0, bin_avg=False, median=False) mab_prob_tri[name] = averageData(mab_prob_tri[name], key=0, value=1, bin_size=1800.0, bin_avg=False, median=False) plot(mab_prob, 0, 1, xlabel="Time elapsed (hr)", ylabel="log(Weight)", title="MAB Probability", outfile="mab_probability_%s.png" % name, xunit=3600.0, xstep=4); plot(mab_prob_tri, 0, 1, xlabel="Time elapsed (hr)", ylabel="Probability", title="", outfile="mab_probability_tri.png", xunit=3600.0, xstep=4); plot(mab_prob_mg, 0, 1, xlabel="Time elapsed (hr)", ylabel="log(Pr(Mutate) / Pr(Generate))", title="", outfile="mab_probability_mg.png", xunit=3600.0, xstep=4);
def plotWork(tests=["KCOV", "RAMINDEX"]): ''' for test in tests: try: __plotWork(test) except: traceback.print_exc() ''' modules = {} # Determine whether we should split by module for test in tests: print(test) name, module, run = getTestParams(test) if not module in modules: modules[module] = [] modules[module].append(test) for module in modules: data = {} exec_time = [] for test in modules[module]: try: __data, exec_time = loadDataCached('work_%s.cache', test, __processTest) print(test, len(__data), __data[-1] if len(__data) > 0 else -1) name, module, run = getTestParams(test) print(name, module, run) if not name in data: data[name] = [] data[name].append(__data) # Time distribution tmp = { "Median": {}, #"99 Percentile": {}, "Q3+IQR": {}, } __keys = ["Generate", "Mutate", "Triage", "All"] exec_time.append(exec_time[0] + exec_time[1] + exec_time[2]) print("Percentile: ", percentileofscore(exec_time[3], 1.0)) for i in range(4): tmp["Median"][__keys[i]] = np.percentile(exec_time[i], 50) #tmp["99 Percentile"][__keys[i]] = np.percentile(exec_time[i], 99) tmp["Q3+IQR"][__keys[i]] = 2 * np.percentile( exec_time[i], 75) + np.percentile(exec_time[i], 25) print(tmp) # plotBar1(tmp, ylabel="Time (s)", outfile="work_time_percentile_%s.png" % test) except: traceback.print_exc() continue # Average / median result # Time Total tmp = {} for name in data: for job in ["Generate", "Mutate", "Triage"]: tmp[name + "_" + job] = averageData(data[name], key="Time_Elapsed", value="Total_Time_" + job, bin_size=600) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Time (s)", outfile="work_%s_time_total.png" % module, ylogscale=False, xunit=3600.0, nmarkers=13, xstep=4) tmp = {} for name in data: tmp[name + "_All"] = averageData(data[name], key="Time_Elapsed", value="Total_Time_All", bin_size=600) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Time (s)", outfile="work_%s_time_total_all.png" % module, ylogscale=False, xunit=3600.0, nmarkers=13, xstep=4) # Execute Time tmp = {} for name in data: for job in ["Generate", "Mutate", "Triage"]: tmp[name + "_" + job] = averageData(data[name], key="Time_Elapsed", value="Execute_Time_" + job, bin_size=600) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Time (s)", outfile="work_%s_time_execute.png" % module, ylogscale=False, xunit=3600.0, nmarkers=13, xstep=4) tmp = {} for name in data: tmp[name + "_All"] = averageData(data[name], key="Time_Elapsed", value="Execute_Time_All", bin_size=600) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Time (s)", outfile="work_%s_time_execute_all.png" % module, ylogscale=False, xunit=3600.0, nmarkers=13, xstep=4) # Overall Choices __plotWorkDist(data, module=module, key="Works_Done", ylabel="Choice", ylogscale=True) # Syscalls made #tmp = {} #for name in data: # for job in ["Generate", "Mutate", "Triage"]: # tmp[name + "_" + job] = averageData(data[name], key="Time_Elapsed", value="Syscalls_Made_" + job, bin_size=600) #plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Syscalls", outfile="work_%s_syscalls.png" % module, ylogscale=False); # Programs Executed __plotWorkDist(data, module=module, key="Programs_Executed", ylabel="Programs", ylogscale=True, yrange=(1000, 10000000))
def plotCoverage(tests=["RAMINDEX", "KCOV"]): modules = {} # Determine whether we should split by module splitByModule = False for test in tests: print(test) name, module, run = getTestParams(test) if not module in modules: modules[module] = [] modules[module].append(test) cov_median = {} cov_mean = {} for module in modules: data = {} for test in modules[module]: try: __data = loadDataCached('coverage_%s.cache', test, __processTestAltAlt); print(test, len(__data), __data[-1] if len(__data) > 0 else -1) name, module, run = getTestParams(test) print(name, module, run) #plot({test: __data}, "Time_Elapsed", "Total_Coverage", xlabel="Time elapsed (min)", ylabel="Coverage", title="Coverage", outfile="coverage_%s_time.png" % test); if not name in data: data[name] = [] data[name].append(__data); except: traceback.print_exc(); pass; # Cliff's Delta tmp = {} for name0 in data: if "Default" in name0: continue for name1 in data: if not "Default" in name1: continue tmp[name0] = cliffsDelta(data[name0], data[name1], key="Time_Elapsed", value="Total_Coverage", bin_size=600) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Cliff's Delta", outfile="coverage_cd_time.png", xunit=3600.0, nmarkers=13, xstep=4); # Average / median result print("Median") tmp = {} for name in data: tmp[name] = averageData(data[name], key="Time_Elapsed", value="Total_Coverage", bin_size=600) print(name, tmp[name][-1]) cov_median[module.replace('dev-', '').capitalize() + '_' + name] = tmp[name] plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Coverage (1000 edges)", outfile="coverage_%s_time.png" % module, xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4, legendout=False); print("25-75") tmp = {} for name in data: tmp[name+"_25%"] = averageData(data[name], key="Time_Elapsed", value="Total_Coverage", bin_size=600, percentile=25) tmp[name+"_75%"] = averageData(data[name], key="Time_Elapsed", value="Total_Coverage", bin_size=600, percentile=75) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Coverage (1000 edges)", outfile="coverage_%s_time_2575.png" % module, xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4, legendout=False); print("Mean") tmp = {} for name in data: tmp[name] = averageData(data[name], key="Time_Elapsed", value="Total_Coverage", bin_size=600, median=False) print(name, tmp[name][-1]) cov_mean[module.replace('dev-', '').capitalize() + '_' + name] = tmp[name] plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Coverage (1000 edges)", outfile="coverage_%s_time_mean.png" % module, xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4); # Seed count print("Seed count") tmp = {} for name in data: tmp[name] = averageData(data[name], key="Time_Elapsed", value="Seed_Count", bin_size=600, median=False) print(name, tmp[name][-1]) cov_mean[module.replace('dev-', '').capitalize() + '_' + name] = tmp[name] plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Number of seeds (1000)", outfile="seed_%s_time.png" % module, xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4); #tmp = {} #for name in data: # tmp[name] = averageData(data[name], key="Syscall_Count", value="Total_Coverage") #plot(tmp, 0, 1, xlabel="Syscalls executed", ylabel="Coverage", title="Coverage", outfile="coverage_%s_call.png" % module); #tmp = {} #for name in data: # tmp[name] = averageData(data[name], key="Program_Count", value="Total_Coverage") #plot(tmp, 0, 1, xlabel="Programs executed", ylabel="Coverage", title="Coverage", outfile="coverage_%s_prog.png" % module); tmp = {} for name in data: tmp[name] = averageData(data[name], key="Time_Elapsed", value="Corpus_Coverage", bin_size=600) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Corpus Signal", title="Coverage", outfile="corpusSig_%s_time.png" % module, xunit=3600.0, nmarkers=13, xstep=4); plot(cov_median, 0, 1, xlabel="Time elapsed (hr)", ylabel="Coverage (1000 edges)", outfile="coverage_all_time.png", xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4); plot(cov_median, 0, 1, xlabel="Time elapsed (hr)", ylabel="Coverage (1000 edges)", outfile="coverage_all_time_small.png", xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4, small=True); plot(cov_mean, 0, 1, xlabel="Time elapsed (hr)", ylabel="Coverage (1000 edges)", outfile="coverage_all_time_mean.png", xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4);
def plotCrashes(tests=["KCOV", "RAMINDEX"]): datas = {} for test in tests: name, module, run = getTestParams(test) name = name + '_' + module if not name in datas: datas[name] = [] for test in tests: name, module, run = getTestParams(test) name = name + '_' + module print("Plotting crashes for %s" % test) __data = None try: # p_all, p_generated, p_corpus, p_triage, __data = __processTest(test); __data = loadDataCached('crashes_%s.cache', test, __processTest) #__data = __processTest(test) datas[name].append(__data) except: traceback.print_exc() continue buildCrashDb(datas) # Crash count crash_count = {} crashes_avg = {} for name in datas: crash_count[name] = [] for d in datas[name]: ts = [] for cid in d: ts.append(d[cid]["ts"]) ts.sort() tmp = [(0, 0)] + [(ts[i], i + 1) for i in range(len(ts))] crash_count[name].append(tmp) crashes_avg[name] = averageData(crash_count[name], key=0, value=1, bin_size=600) # print(crash_count[name]) plot(crashes_avg, 0, 1, xlabel="Time elapsed (hr)", ylabel="Crahses Found", title="", outfile="crashes_time.png", xunit=3600.0, nmarkers=12, xstep=4) # Cliff's delta tmp = {} for name0 in crash_count: if "Default" in name0: continue for name1 in crash_count: if not "Default" in name1: continue tmp[name0] = cliffsDelta(crash_count[name0], crash_count[name1], key=0, value=1, bin_size=600) plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Cliff's Delta", outfile="crashes_cd_time.png", xunit=3600.0, nmarkers=12, xstep=4)
def plotPrograms(tests=["KCOV", "RAMINDEX"]): datas = {} datas_pgsize = {} datas_cpsize = {} tmax = 0 cmax = 0 bin_size = 3600 datas_jobpower_sum = {} datas_seedpower = {} datas_seednum = {} datas_seedpower_avg = {} datas_seedpower_sum = {} datas_seedpower_sum_avg = {} datas_mutlp = {} datas_mutep = {} datas_mutls = {} datas_jobpower = {} for test in tests: name, module, run = getTestParams(test) # name = name + '_' + module if not name in datas_seedpower: datas_seednum[name] = { "Generate": [], "Mutate": [], "Triage": [], "All": [], } datas_seedpower[name] = { "Generate": [], "Mutate": [], "Triage": [], "All": [], } datas_seedpower_avg[name] = { "Generate": [], "Mutate": [], "Triage": [], "All": [], } datas_seedpower_sum[name] = { "Generate": [], "Mutate": [], "Triage": [], } datas_seedpower_sum_avg[name] = { "Generate": [], "Mutate": [], "Triage": [], "All": [], } datas_jobpower_sum[name] = { "Generate": [], "Mutate": [], "Triage": [], } datas_jobpower[name] = { "Generate": [], "Mutate": [], "Triage": [], } datas_mutls[name] = { "Total_Mutations": [], "Last_Eff_Mutation": [], "Eff_Mutation": [] } datas_mutlp[name] = [] datas_mutep[name] = [] for test in tests: name, module, run = getTestParams(test) # name = name + '_' + module print("Plotting programs for %s" % test) try: # p_all, p_generated, p_corpus, p_triage, __data = __processTest(test); p_all, p_generated, p_corpus, p_triage, __data = loadDataCached( 'program_%s.cache', test, __processTest) for i in range(len(p_all)): if type(p_all[i]) == dict: p_all[i] = Program.FromDict(p_all[i]) except: traceback.print_exc() continue #plotMutation(p_all, test) print(len(p_all)) print(len(p_generated)) print(len(p_corpus)) print(len(p_triage)) print(__data[-1]) datas_jobpower_sum[name]["Generate"].append( __data[-1]["Generate_Coverage"]) datas_jobpower_sum[name]["Mutate"].append( __data[-1]["Mutate_Coverage"]) datas_jobpower_sum[name]["Triage"].append( __data[-1]["Minimize_Coverage"]) # Accumulated datas[test] = { "Generation": [(v["Time_Elapsed"], v["Generate_Coverage"]) for v in __data], "Minimization": [(v["Time_Elapsed"], v["Minimize_Coverage"]) for v in __data], "Mutation": [(v["Time_Elapsed"], v["Mutate_Coverage"]) for v in __data], } datas_jobpower[name]["Generate"].append(datas[test]["Generation"]) datas_jobpower[name]["Triage"].append(datas[test]["Minimization"]) datas_jobpower[name]["Mutate"].append(datas[test]["Mutation"]) datas[test + "_average"] = { "Generation": [(v["Time_Elapsed"], v["Generate_Coverage"] / v["Generate_Count"] if v["Generate_Count"] > 0 else 0) for v in __data], "Minimization": [(v["Time_Elapsed"], v["Minimize_Coverage"] / v["Minimize_Count"] if v["Minimize_Count"] > 0 else 0) for v in __data], "Mutation": [(v["Time_Elapsed"], v["Mutate_Coverage"] / v["Mutate_Count"] if v["Mutate_Count"] > 0 else 0) for v in __data], } #plot(datas[test], 0, 1, xlabel="Time elapsed (hr)", ylabel="Total coverage (# edges)", title="", outfile="programs_%s.png" % test, xunit=3600.0); #plot(datas[test+"_average"], 0, 1, xlabel="Time elapsed (hr)", ylabel="Average coverage (# edges)", title="", outfile="programs_%s_avg.png" % test, ylogscale=True, xunit=3600); plot2( (datas[test], datas[test + "_average"]), (0, 0), (1, 1), xlabel=("Time elapsed (hr)", "Time elapsed (hr)"), ylabel=("Total coverage (# edges)", "Average coverage (# edges)"), outfile="programs_coverage_%s.png" % test, ylogscale=[True, True], xunit=(3600.0, 3600.0)) # By bins ''' data_bin = { "Generate_Coverage": __binSplit(__data, x="Time_Elapsed", y="Generate_Coverage", c="Generate_Count", bin_size=bin_size)[0], "Minimize_Coverage": __binSplit(__data, x="Time_Elapsed", y="Minimize_Coverage", c="Minimize_Count", bin_size=bin_size)[0], "Mutate_Coverage": __binSplit(__data, x="Time_Elapsed", y="Mutate_Coverage", c="Mutate_Count", bin_size=bin_size)[0] } data_bin_avg = { "Generate_Coverage": __binSplit(__data, x="Time_Elapsed", y="Generate_Coverage", c="Generate_Count", bin_size=bin_size)[1], "Minimize_Coverage": __binSplit(__data, x="Time_Elapsed", y="Minimize_Coverage", c="Minimize_Count", bin_size=bin_size)[1], "Mutate_Coverage": __binSplit(__data, x="Time_Elapsed", y="Mutate_Coverage", c="Mutate_Count", bin_size=bin_size)[1] } plotBar(data_bin, 0, 1, width=bin_size, xlabel="Time elapsed (hr)", ylabel="# of signals", title="", outfile="programs_bin_%s.png" % test, xunit=3600.0); plotBar(data_bin_avg, 0, 1, width=bin_size, xlabel="Time elapsed (hr)", ylabel="# of signals", title="", outfile="programs_bin_avg_%s.png" % test, xunit=3600.0); ''' # Program size datas_pgsize[test] = [p.size for p in p_all] datas_cpsize[test] = [] for psig in p_corpus: p = p_all[p_corpus[psig]] #if p_all[p].inCorpus: datas_cpsize[test].append(p.size) # Source of seed seed_source = [0, 0, 0] for psig in p_corpus: p = p_all[p_corpus[psig]] #if p_corpus[p].inCorpus: if p.corpusSource == "Generate": seed_source[0] += 1 elif p.corpusSource == "Mutate": seed_source[1] += 1 elif p.corpusSource == "Minimize": seed_source[2] += 1 print(seed_source) # Mutation lifespan data_ls = { "Total_Mutations": [], "Last_Eff_Mutation": [], "Eff_Mutation": [], } data_lp = { "Lifespan_Percentage": [], } data_ep = { "Eff_Percentage": [], } for psig in p_corpus: p = p_all[p_corpus[psig]] #if p_corpus[p].inCorpus: tm = len(p.children) lm = 0 em = 0 for _c in range(len(p.children)): c = p_all[p.children[_c]] if len(c.coverage) > 0: lm = _c em += 1 data_ls["Total_Mutations"].append(tm) data_ls["Last_Eff_Mutation"].append(lm) data_ls["Eff_Mutation"].append(em) if tm > 0: data_lp["Lifespan_Percentage"].append(float(lm) / float(tm)) data_ep["Eff_Percentage"].append(float(em) / float(tm)) else: data_lp["Lifespan_Percentage"].append(0.0) data_ep["Eff_Percentage"].append(0.0) for dn in data_ls: datas_mutls[name][dn] += data_ls[dn] datas_mutlp[name] += data_lp["Lifespan_Percentage"] datas_mutep[name] += data_ep["Eff_Percentage"] #plotCDF(data_ls, xlabel="# Mutations", ylabel="CDF", title="", outfile="mutations_lifespan_%s.png" % test); #plotCDF(data_lp, xlabel="Percentage", ylabel="CDF", title="", outfile="mutations_lifespan_percentage_%s.png" % test); # Seed power data_seedpower = { "Generate": [], "Mutate": [], "Triage": [], "All": [], } data_seedpower_avg = { "Generate": [], "Mutate": [], "Triage": [], "All": [], } data_seedpower_sum = {"Generate": 0, "Mutate": 0, "Triage": 0} data_seednum = {"Generate": 0, "Mutate": 0, "Triage": 0, "All": 0} for psig in p_corpus: p = p_all[p_corpus[psig]] #if p.inCorpus: cov = 0 origin = p.corpusSource if origin == "Minimize": origin = "Triage" if origin is None: print("WTF") print(psig) continue data_seednum[origin] += 1 data_seednum["All"] += 1 for _c in p.children: c = p_all[_c] cov += len(c.coverage) data_seedpower[origin].append(cov) data_seedpower["All"].append(cov) data_seedpower_sum[origin] += cov if len(p.children) > 0: data_seedpower_avg[origin].append(cov / len(p.children)) data_seedpower_avg["All"].append(cov / len(p.children)) # print(data_seedpower_avg) for job in data_seednum: datas_seednum[name][job].append(data_seednum[job]) for job in datas_seedpower[name]: datas_seedpower[name][job] += data_seedpower[job] datas_seedpower_avg[name][job] += data_seedpower_avg[job] for job in data_seedpower_sum: datas_seedpower_sum[name][job].append(data_seedpower_sum[job]) datas_seedpower_sum_avg[name][job].append( data_seedpower_sum[job] / len(data_seedpower[job]) if len(data_seedpower[job]) > 0 else 0.0) datas_seedpower_sum_avg[name]["All"].append( (data_seedpower_sum["Generate"] + data_seedpower_sum["Mutate"] + data_seedpower_sum["Triage"]) / len(data_seedpower["All"]) if len(data_seedpower["All"]) > 0 else 0.0) tmp = {} tmp_break = {} for name in datas_seedpower: plotCDF(datas_mutls[name], xlabel="# Mutations", ylabel="CDF", title="", outfile="mutations_lifespan_%s.png" % name, xrange=(-10, 210), small=True) plotCDF(datas_seedpower[name], xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_%s.png" % name, xrange=(-0.5, 1005), xlogscale=True, small=False) plotCDF(datas_seedpower_avg[name], xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_avg_%s.png" % name, xrange=(-0.5, 10), xlogscale=False, small=False) tmp[name] = datas_seedpower[name]["All"] if "SS" in name: for job in ["Generate", "Mutate", "Triage"]: tmp_break[name + "_" + job] = datas_seedpower[name][job] plotCDF(tmp, xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_all.png", xrange=(-0.5, 1005), xlogscale=True) plotCDF(tmp_break, xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_breakdown.png", xrange=(-0.5, 1005), xlogscale=True) plotCDF(tmp_break, xlabel="Coverage", ylabel="# of seeds", title="", outfile="seed_power_breakdown_raw.png", xrange=(-0.5, 1005), xlogscale=True, raw=True) # Seed power sum #for name in datas_seedpower_sum: # for job in datas_seedpower_sum[name]: # datas_seedpower_sum[name][job] = np.median(datas_seedpower_sum[name][job]) plotBar1(datas_seednum, ylabel="# seeds", outfile="seed_num.png") print("Seed Numbers") plotBar1(datas_seedpower_sum, ylabel="Coverage", outfile="seed_power_sum.png") plotBar1(datas_seedpower_sum_avg, ylabel="Coverage", outfile="seed_power_sum_avg.png") plotBar1(datas_jobpower_sum, ylabel="Coverage (1000 edges)", outfile="work_power_sum.png", yunit=1000.0) plotCDF(datas_mutlp, xlabel="Percentage", ylabel="CDF", title="", outfile="mutations_lifespan_percentage.png", xrange=(-0.05, 1.05)) plotCDF(datas_mutep, xlabel="Percentage", ylabel="CDF", title="", outfile="mutations_eff_percentage.png", xrange=(-0.05, 1.05)) plotCDF(datas_pgsize, xlabel="Program Size", ylabel="CDF", title="", outfile="programs_size.png") plotCDF(datas_cpsize, xlabel="Corpus Size", ylabel="CDF", title="", outfile="corpus_size.png") for name in datas_jobpower: for task in ["Generate", "Mutate", "Triage"]: datas_jobpower[name][task] = averageData( datas_jobpower[name][task], key=0, value=1, bin_size=600) plot(datas_jobpower[name], 0, 1, xlabel="Time elapsed (hr)", ylabel="Coverage (1000 edges)", outfile="work_power_growth_%s.png" % name, xunit=3600.0, yunit=1000.0, nmarkers=13, xstep=4)