Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
SoveraNia committed Jan 19, 2020
1 parent 6fe8748 commit a025b4c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 60 deletions.
8 changes: 7 additions & 1 deletion analyze/analyze_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ def plotCoverage(tests=["RAMINDEX", "KCOV"]):
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);
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:
Expand Down
2 changes: 1 addition & 1 deletion analyze/analyze_mutationtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def sampleTree(trees, nodes, samplerate=0.05, maxlevel=100):
print(trees_sample, len(nodes_sample_dedup))
return trees_sample, nodes_sample_dedup

def plotForest(trees, nodes, samplerate=1.0, prunerate=0.0, maxnodes=500, maxtrees=100000, maxlevel=50, outfile="tree.png"):
def plotForest(trees, nodes, samplerate=1.0, prunerate=0.0, maxnodes=500, maxtrees=100000, maxlevel=5000, outfile="tree.png"):
#if maxnodes / len(nodes) < samplerate / 2:
samplerate = maxnodes * 2.0 / len(nodes)
AG = PG.AGraph(directed=True, strict=True)
Expand Down
24 changes: 19 additions & 5 deletions analyze/analyze_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pygraphviz as PG

from plot import plot, plotBar, plotCDF, plotBar1, plot2
from utils import loadDataCached, getTestParams
from utils import loadDataCached, getTestParams, averageData

class Program:
def __init__(self, sig):
Expand Down Expand Up @@ -329,6 +329,7 @@ def plotPrograms(tests=["KCOV", "RAMINDEX"]):
datas_mutlp = {}
datas_mutep = {}
datas_mutls = {}
datas_jobpower = {}
for test in tests:
name, module, run = getTestParams(test)
# name = name + '_' + module
Expand Down Expand Up @@ -367,6 +368,11 @@ def plotPrograms(tests=["KCOV", "RAMINDEX"]):
"Mutate": [],
"Minimize": [],
}
datas_jobpower[name] = {
"Generate": [],
"Mutate": [],
"Triage": [],
}
datas_mutls[name] = {
"Total_Mutations": [],
"Last_Eff_Mutation": [],
Expand Down Expand Up @@ -403,6 +409,9 @@ def plotPrograms(tests=["KCOV", "RAMINDEX"]):
"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],
Expand Down Expand Up @@ -539,9 +548,9 @@ def plotPrograms(tests=["KCOV", "RAMINDEX"]):
datas_seedpower_sum_avg[name]["All"].append((data_seedpower_sum["Generate"] + data_seedpower_sum["Mutate"] + data_seedpower_sum["Minimize"]) / len(data_seedpower["All"]) if len(data_seedpower["All"]) > 0 else 0.0)
tmp = {}
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=True);
plotCDF(datas_seedpower_avg[name], xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_avg_%s.png" % name, xrange=(-0.5,10), xlogscale=False, small=True);
plotCDF(datas_mutls[name], xlabel="# Mutations", ylabel="CDF", title="", outfile="mutations_lifespan_%s.png" % name, xrange=(-10, 210), small=False);
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"]
plotCDF(tmp, xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_all.png", xrange=(-0.5, 1005), xlogscale=True);
# Seed power sum
Expand All @@ -551,11 +560,16 @@ def plotPrograms(tests=["KCOV", "RAMINDEX"]):
plotBar1(datas_seednum, ylabel="# seeds", outfile="seed_num.png")
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", outfile="work_power_sum.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);

33 changes: 18 additions & 15 deletions analyze/analyze_work.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,24 @@ def __plotWork(test):
#plot(data, 0, 2, xlabel="# of executions", ylabel="# of executions", title="", outfile="work_%s.png" % test, ylogscale=False);
plot(data, 1, 2, xlabel="Time elapsed (hr)", ylabel="# of executions", title="", outfile="work_time_%s.png" % test, ylogscale=False, xunit=3600.0);

def __plotWorkDist(data, key, module="", ylogscale=False, ylabel=""):
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[name + "_" + job] = averageData(data[name], key="Time_Elapsed", value=key + "_" + job, bin_size=10)
plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel=ylabel, outfile="work_%s_%s.png" % (module, key), ylogscale=ylogscale, xunit=3600.0);
__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);
plotBar1(tmp, ylabel=ylabel, outfile="work_%s_%s_bar.png" % (module, key), ylogscale=ylogscale, yrange=yrange);


def plotWork(tests=["KCOV", "RAMINDEX"]):
Expand Down Expand Up @@ -217,7 +220,7 @@ def plotWork(tests=["KCOV", "RAMINDEX"]):
#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)
# plotBar1(tmp, ylabel="Time (s)", outfile="work_time_percentile_%s.png" % test)
except:
traceback.print_exc()
continue
Expand All @@ -228,31 +231,31 @@ def plotWork(tests=["KCOV", "RAMINDEX"]):
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=10)
plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Time (s)", outfile="work_%s_time_total.png" % module, ylogscale=False, xunit=3600.0, nmarkers=12);
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=10)
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=12);
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=10)
plot(tmp, 0, 1, xlabel="Time elapsed (hr)", ylabel="Time (s)", outfile="work_%s_time_execute.png" % module, ylogscale=False, xunit=3600.0, nmarkers=12);
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=10)
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=12);
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=10)
# 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)
__plotWorkDist(data, module=module, key="Programs_Executed", ylabel="Programs", ylogscale=True, yrange=(1000,10000000))


92 changes: 58 additions & 34 deletions analyze/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

linecolors = ["r", "g", "b", "black"]
markers = ['s', 'o', '^', 'v', '+', 'x', 'd']
markers = ['s', 'o', '^', 'v', 'd', '+', 'x', '2']
fillcolors = ["tab:red", "tab:olive", "tab:blue", "tab:cyan"]
patterns = ['--', 'xx', '++', '\\\\', '**', '..']
linestyles = ["-",
Expand Down Expand Up @@ -101,27 +101,28 @@ def plot2(data, key, value, xlabel=["",""], ylabel=["",""], title=["",""], outfi


def plot(data, key, value, xlabel="", ylabel="", title="", outfile="out.png",
xlogscale=False, ylogscale=False, xmax=None, ymax=None, scatter=False, xunit=1.0, yunit=1.0, nmarkers=12, xstep=None, small=False):
xlogscale=False, ylogscale=False, xmax=None, ymax=None, scatter=False, xunit=1.0, yunit=1.0, nmarkers=12, xstep=None, small=False, legendout=True):
fig = None
ax = None
total_test_len = 0
for test in data.keys():
total_test_len += len(test)
bbox_to_anchor = False
if len(data.keys()) > 4 or total_test_len > 40:
if legendout:
if len(data.keys()) > 6 or total_test_len > 200:
bbox_to_anchor = True
if small:
fig = plt.figure(figsize=(4,4))
ax = plt.subplot(111)
plt.subplots_adjust(left=0.2, bottom=0.2, right=0.95, top=0.98, wspace=0, hspace=0)
else:
fig = plt.figure(figsize=(8,5))
fig = plt.figure(figsize=(6,5))
ax = plt.subplot(111)
# plt.subplots_adjust(left=0.12, bottom=0.15, right=0.95, top=0.98, wspace=0, hspace=0)
if bbox_to_anchor:
plt.subplots_adjust(left=0.12, bottom=0.15, right=0.75, top=0.98, wspace=0, hspace=0)
plt.subplots_adjust(left=0.15, bottom=0.15, right=0.65, top=0.98, wspace=0, hspace=0)
else:
plt.subplots_adjust(left=0.12, bottom=0.15, right=0.95, top=0.98, wspace=0, hspace=0)
plt.subplots_adjust(left=0.15, bottom=0.15, right=0.95, top=0.98, wspace=0, hspace=0)

ax.set_title(title, fontsize=20);
ax.set_xlabel(xlabel, fontsize=16);
Expand Down Expand Up @@ -166,36 +167,15 @@ def plot(data, key, value, xlabel="", ylabel="", title="", outfile="out.png",
plt.savefig(outfile + '.pdf');
plt.close('all');

def plotBar1(data, width=1, xlabel="", ylabel="", title="", outfile="out.png",
xlogscale=False, ylogscale=False, xmax=None, ymax=None, small=False):
fig = None
ax = None
total_test_len = 0
for test in data.keys():
total_test_len += len(test)
bbox_to_anchor = False
if len(data.keys()) > 4 or total_test_len > 40:
bbox_to_anchor = True
if small:
fig = plt.figure(figsize=(4,4))
ax = plt.subplot(111)
plt.subplots_adjust(left=0.2, bottom=0.2, right=0.95, top=0.98, wspace=0, hspace=0)
else:
fig = plt.figure(figsize=(8,5))
ax = plt.subplot(111)
if bbox_to_anchor:
plt.subplots_adjust(left=0.12, bottom=0.08, right=0.8, top=0.98, wspace=0, hspace=0)
else:
plt.subplots_adjust(left=0.12, bottom=0.08, right=0.95, top=0.98, wspace=0, hspace=0)
def plotBarAx(ax, data, width=1, xlabel="", ylabel="", title="",
xlogscale=False, ylogscale=False, yrange=None, small=False, yunit=1.0):
ax.set_title(title, fontsize=20);
ax.set_xlabel(xlabel, fontsize=16);
ax.set_ylabel(ylabel, fontsize=16);
ax.tick_params(labelsize=12);

if not xmax is None:
ax.set_xlim(0,xmax);
if not ymax is None:
ax.set_ylim(0,ymax);
if not yrange is None:
ax.set_ylim(yrange[0],yrange[1]);
if xlogscale:
ax.set_xscale('symlog')
if ylogscale:
Expand All @@ -213,14 +193,58 @@ def plotBar1(data, width=1, xlabel="", ylabel="", title="", outfile="out.png",
y_std = []
for key in labels:
x.append(len(x) * width + (idx+0.5)*bar_width);
y_mean.append(np.mean(data[test][key]))
y_std.append(np.std(data[test][key]))
y_mean.append(np.mean(data[test][key]) / yunit)
y_std.append(np.std(data[test][key]) / yunit)
tlabel = test.replace("KCOV", "").replace('_', ' ').strip()
ax.bar(x,y_mean, yerr=y_std, width=bar_width, label=tlabel, color=fillcolors[idx%len(fillcolors)], edgecolor='black', hatch=patterns[idx % len(patterns)]);
idx += 1;
ax.grid();
ax.set_xticks([(width * i + len(data.keys()) * bar_width / 2) for i in range(len(labels))])
ax.set_xticklabels(labels)

def plotBar2(data, xlabel=["",""], ylabel=["",""], title=["",""], outfile="out.png",
xlogscale=[False,False], ylogscale=[False,False], xmax=[None,None], ymax=[None,None], yunit=[1.0,1.0]):
ax = [None, None]
fig = plt.figure(figsize=(8,5))
# fig, (ax[0], ax[1]) = plt.subplots(1, 2, figsize=(8,5), subplotpars=SubplotParams(top=0.98,bottom=0.2,right=0.95,left=0.2,hspace=0.2,wspace=0))
lines = []
labels = []
for i in range(2):
ax[i] = plt.subplot(1,2,i+1)
lines, labels = __plotAx(ax[i], data[i], key[i], value[i], xlabel=xlabel[i], ylabel=ylabel[i], title=title[i], xlogscale=xlogscale[i], ylogscale=ylogscale[i], xmax=xmax[i], ymax=ymax[i], scatter=scatter[i], xunit=xunit[i], yunit=yunit[i], nmarkers=nmarkers[i], xstep=xstep[i], small=True)
fig.subplots_adjust(bottom=0.25,top=0.98,left=0.12,right=0.99,wspace=0.35)
#fig.tight_layout(pad=3.0)
fig.legend(lines, labels=labels, fontsize=12, loc=8, ncol=len(lines))
plt.savefig(outfile);
plt.savefig(outfile + '.pdf');
plt.close('all');


def plotBar1(data, width=1, xlabel="", ylabel="", title="", outfile="out.png",
xlogscale=False, ylogscale=False, yrange=None, small=False, yunit=1.0):
fig = None
ax = None
total_test_len = 0
for test in data.keys():
total_test_len += len(test)
bbox_to_anchor = False
if len(data.keys()) > 4 or total_test_len > 60:
bbox_to_anchor = True
if small:
fig = plt.figure(figsize=(4,4))
ax = plt.subplot(111)
plt.subplots_adjust(left=0.2, bottom=0.2, right=0.95, top=0.98, wspace=0, hspace=0)
else:
fig = plt.figure(figsize=(6,5))
ax = plt.subplot(111)
if bbox_to_anchor:
plt.subplots_adjust(left=0.12, bottom=0.08, right=0.95, top=0.98, wspace=0, hspace=0)
else:
plt.subplots_adjust(left=0.12, bottom=0.08, right=0.95, top=0.98, wspace=0, hspace=0)

plotBarAx(ax, data, width=width, xlabel=xlabel, ylabel=ylabel, title=title,
xlogscale=xlogscale, ylogscale=ylogscale, yrange=yrange, small=small, yunit=yunit)

if bbox_to_anchor:
ax.legend(bbox_to_anchor=(1.01, 1.0),fontsize=12)
else:
Expand Down Expand Up @@ -330,7 +354,7 @@ def plotCDF(data, key=None, value=None, xlabel="", ylabel="CDF", title="", outfi
ax = plt.subplot(111)
plt.subplots_adjust(left=0.2, bottom=0.2, right=0.95, top=0.98, wspace=0, hspace=0)
else:
fig = plt.figure(figsize=(8,5))
fig = plt.figure(figsize=(6,5))
ax = plt.subplot(111)
plt.subplots_adjust(left=0.15, bottom=0.15, right=0.95, top=0.95, wspace=0, hspace=0)
ax.set_title(title, fontsize=20);
Expand Down
Loading

0 comments on commit a025b4c

Please sign in to comment.