plot enpoints

This commit is contained in:
Alwin Berger 2023-05-25 08:39:47 +02:00
parent 8b90886299
commit 1bca346b39

View File

@ -11,8 +11,8 @@ registerDoParallel(cl)
args = commandArgs(trailingOnly=TRUE) args = commandArgs(trailingOnly=TRUE)
if (length(args)==0) { if (length(args)==0) {
runtype="timedump_253048_1873f6_full/timedump" runtype="timedump_253048_1873f6_all/timedump"
target="watersv2" target="waters"
outputpath="~/code/FRET/LibAFL/fuzzers/FRET/benchmark/" outputpath="~/code/FRET/LibAFL/fuzzers/FRET/benchmark/"
#MY_SELECTION <- c('state', 'afl', 'graph', 'random') #MY_SELECTION <- c('state', 'afl', 'graph', 'random')
SAVE_FILE=TRUE SAVE_FILE=TRUE
@ -40,6 +40,7 @@ RIBBON='both'
DRAW_WC = worst_case > 0 DRAW_WC = worst_case > 0
LEGEND_POS="topleft" LEGEND_POS="topleft"
#LEGEND_POS="bottomright" #LEGEND_POS="bottomright"
CONTINUE_LINE_TO_END=TRUE
# https://www.r-bloggers.com/2013/04/how-to-change-the-alpha-value-of-colours-in-r/ # https://www.r-bloggers.com/2013/04/how-to-change-the-alpha-value-of-colours-in-r/
alpha <- function(col, alpha=1){ alpha <- function(col, alpha=1){
@ -108,22 +109,26 @@ trace2maxpoints <- function(tr) {
sample_maxpoints <- function(tr,po) { sample_maxpoints <- function(tr,po) {
index = 1 index = 1
collect=NULL collect=NULL
endpoint = dim(tr)[1]
for (p in po) { for (p in po) {
done = FALSE if (p<=tr[1,2]) {
while (!done) { tmp = tr[index,]
if (p<=tr[1,2] || (index < dim(tr)[1] && tr[index,2] <= p && p < tr[index+1,2])) { tmp[2] = p
tmp = tr[index,] collect = rbind(collect, tmp)
tmp[2] = p } else if (p>=tr[endpoint,2]) {
collect = rbind(collect, tmp) tmp = tr[endpoint,]
done = TRUE tmp[2] = p
} else { if ( p >= tr[dim(tr)[1],2] ) { collect = rbind(collect, tmp)
tmp = tr[dim(tr)[1],] } else {
tmp[2] = p for (i in seq(index,endpoint)-1) {
collect = rbind(collect, tmp) if (p >= tr[i,2] && p<tr[i+1,2]) {
done = TRUE tmp = tr[i,]
} else { tmp[2] = p
index = index + 1 collect = rbind(collect, tmp)
} } index = i
break
}
}
} }
} }
return(collect) return(collect)
@ -145,10 +150,25 @@ all_runtypetables <- foreach (bn=BASENAMES) %do% {
} }
} }
all_runtypetables = all_runtypetables[lapply(all_runtypetables, length) > 0] all_runtypetables = all_runtypetables[lapply(all_runtypetables, length) > 0]
all_points = sort(unique(Reduce(c, lapply(all_runtypetables, function(v) Reduce(c, lapply(v, function(w) w[[2]])))))) all_min_points = foreach(rtt=all_runtypetables,.combine = cbind) %do% {
all_maxlines <- foreach (rtt=all_runtypetables) %dopar% {
bn = substr(names(rtt[[1]])[1],1,nchar(names(rtt[[1]])[1])-1) bn = substr(names(rtt[[1]])[1],1,nchar(names(rtt[[1]])[1])-1)
runtypetables_sampled = lapply(rtt, function(v) sample_maxpoints(v, all_points)[1]) ret = data.frame(min(unlist(lapply(rtt, function(v) v[dim(v)[1],2]))))
names(ret)[1] = bn
ret/(3600 * 1000)
}
all_max_points = foreach(rtt=all_runtypetables,.combine = cbind) %do% {
bn = substr(names(rtt[[1]])[1],1,nchar(names(rtt[[1]])[1])-1)
ret = data.frame(max(unlist(lapply(rtt, function(v) v[dim(v)[1],2]))))
names(ret)[1] = bn
ret/(3600 * 1000)
}
all_points = sort(unique(Reduce(c, lapply(all_runtypetables, function(v) Reduce(c, lapply(v, function(w) w[[2]]))))))
all_maxlines <- foreach (rtt=all_runtypetables) %do% {
bn = substr(names(rtt[[1]])[1],1,nchar(names(rtt[[1]])[1])-1)
runtypetables_sampled = foreach(v=rtt) %dopar% {
sample_maxpoints(v, all_points)[1]
}
#runtypetables_sampled = lapply(rtt, function(v) sample_maxpoints(v, all_points)[1])
tmp_frame <- Reduce(cbind, runtypetables_sampled) tmp_frame <- Reduce(cbind, runtypetables_sampled)
statframe <- data.frame(rowMeans(tmp_frame),apply(tmp_frame, 1, sd),apply(tmp_frame, 1, min),apply(tmp_frame, 1, max)) statframe <- data.frame(rowMeans(tmp_frame),apply(tmp_frame, 1, sd),apply(tmp_frame, 1, min),apply(tmp_frame, 1, max))
names(statframe) <- c(bn, sprintf("%s_sd",bn), sprintf("%s_min",bn), sprintf("%s_max",bn)) names(statframe) <- c(bn, sprintf("%s_sd",bn), sprintf("%s_min",bn), sprintf("%s_max",bn))
@ -167,10 +187,13 @@ yhigh=max(one_frame[typenames],worst_case)
typenames = typenames[which(!endsWith(typenames, "_min"))] typenames = typenames[which(!endsWith(typenames, "_min"))]
typenames = typenames[which(!endsWith(typenames, "_max"))] typenames = typenames[which(!endsWith(typenames, "_max"))]
ml2lines <- function(ml) { ml2lines <- function(ml,lim) {
lines = NULL lines = NULL
last = 0 last = 0
for (i in seq_len(dim(ml)[1])) { for (i in seq_len(dim(ml)[1])) {
if (!CONTINUE_LINE_TO_END && lim<ml[i,2]) {
break
}
lines = rbind(lines, cbind(X=last, Y=ml[i,1])) lines = rbind(lines, cbind(X=last, Y=ml[i,1]))
lines = rbind(lines, cbind(X=ml[i,2], Y=ml[i,1])) lines = rbind(lines, cbind(X=ml[i,2], Y=ml[i,1]))
last = ml[i,2] last = ml[i,2]
@ -199,11 +222,11 @@ plot(c(1,max(one_frame['time'])),c(ylow,yhigh), col='white', xlab="Time [h]", yl
for (t in seq_len(length(typenames))) { for (t in seq_len(length(typenames))) {
proj = one_frame[seq(1, dim(one_frame)[1], by=max(1, length(one_frame[[1]])/(10*w_))),] proj = one_frame[seq(1, dim(one_frame)[1], by=max(1, length(one_frame[[1]])/(10*w_))),]
#points(proj[c('iters',typenames[t])], col=MY_COLORS_[t], pch='.') #points(proj[c('iters',typenames[t])], col=MY_COLORS_[t], pch='.')
avglines = ml2lines(one_frame[c(typenames[t],'time')]) avglines = ml2lines(one_frame[c(typenames[t],'time')],all_max_points[typenames[t]])
lines(avglines, col=MY_COLORS_[t]) lines(avglines, col=MY_COLORS_[t])
if (exists("RIBBON") && ( RIBBON=='both' || RIBBON=='span')) { if (exists("RIBBON") && ( RIBBON=='both' || RIBBON=='span')) {
milines = ml2lines(one_frame[c(sprintf("%s_min",typenames[t]),'time')]) milines = ml2lines(one_frame[c(sprintf("%s_min",typenames[t]),'time')],all_max_points[typenames[t]])
malines = ml2lines(one_frame[c(sprintf("%s_max",typenames[t]),'time')]) malines = ml2lines(one_frame[c(sprintf("%s_max",typenames[t]),'time')],all_max_points[typenames[t]])
lines(milines, col=MY_COLORS_[t], lty='dashed') lines(milines, col=MY_COLORS_[t], lty='dashed')
lines(malines, col=MY_COLORS_[t], lty='dashed') lines(malines, col=MY_COLORS_[t], lty='dashed')
#points(proj[c('iters',sprintf("%s_min",typenames[t]))], col=MY_COLORS_[t], pch='.') #points(proj[c('iters',sprintf("%s_min",typenames[t]))], col=MY_COLORS_[t], pch='.')
@ -239,16 +262,17 @@ legend(LEGEND_POS, legend=leglines,#"topleft"
if (SAVE_FILE) {dev.off()} if (SAVE_FILE) {dev.off()}
} }
stopCluster(cl)
par(mar=c(3.8,3.8,0,0)) par(mar=c(3.8,3.8,0,0))
par(oma=c(0,0,0,0)) par(oma=c(0,0,0,0))
if (exists("MY_SELECTION")) { if (exists("MY_SELECTION")) {
plotting(MY_SELECTION, 'custom', MY_COLORS) plotting(MY_SELECTION, 'custom', MY_COLORS)
} else { } else {
#MY_SELECTION=c('state', 'afl', 'random', 'feedlongest', 'feedgeneration', 'feedgeneration10') MY_SELECTION=c('state', 'afl', 'random', 'feedlongest', 'feedgeneration', 'feedgeneration10')
#MY_SELECTION=c('state_int', 'afl_int', 'random_int', 'feedlongest_int', 'feedgeneration_int', 'feedgeneration10_int') #MY_SELECTION=c('state_int', 'afl_int', 'random_int', 'feedlongest_int', 'feedgeneration_int', 'feedgeneration10_int')
#MY_SELECTION=c('state', 'frAFL', 'statenohash', 'feedgeneration10') #MY_SELECTION=c('state', 'frAFL', 'statenohash', 'feedgeneration10')
MY_SELECTION=c('state_int', 'frAFL_int', 'statenohash_int', 'feedgeneration10_int') #MY_SELECTION=c('state_int', 'frAFL_int', 'statenohash_int', 'feedgeneration10_int')
MY_SELECTION=typenames MY_SELECTION=typenames
RIBBON='span' RIBBON='span'
for (i in seq_len(length(MY_SELECTION))) { for (i in seq_len(length(MY_SELECTION))) {