From 1bca346b39a6159cee960419cf0719c2861143d2 Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Thu, 25 May 2023 08:39:47 +0200 Subject: [PATCH] plot enpoints --- fuzzers/FRET/benchmark/plot_multi.r | 76 +++++++++++++++++++---------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/fuzzers/FRET/benchmark/plot_multi.r b/fuzzers/FRET/benchmark/plot_multi.r index 09c3b522dc..9631b27986 100644 --- a/fuzzers/FRET/benchmark/plot_multi.r +++ b/fuzzers/FRET/benchmark/plot_multi.r @@ -11,8 +11,8 @@ registerDoParallel(cl) args = commandArgs(trailingOnly=TRUE) if (length(args)==0) { - runtype="timedump_253048_1873f6_full/timedump" - target="watersv2" + runtype="timedump_253048_1873f6_all/timedump" + target="waters" outputpath="~/code/FRET/LibAFL/fuzzers/FRET/benchmark/" #MY_SELECTION <- c('state', 'afl', 'graph', 'random') SAVE_FILE=TRUE @@ -40,6 +40,7 @@ RIBBON='both' DRAW_WC = worst_case > 0 LEGEND_POS="topleft" #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/ alpha <- function(col, alpha=1){ @@ -108,22 +109,26 @@ trace2maxpoints <- function(tr) { sample_maxpoints <- function(tr,po) { index = 1 collect=NULL + endpoint = dim(tr)[1] for (p in po) { - done = FALSE - while (!done) { - if (p<=tr[1,2] || (index < dim(tr)[1] && tr[index,2] <= p && p < tr[index+1,2])) { - tmp = tr[index,] - tmp[2] = p - collect = rbind(collect, tmp) - done = TRUE - } else { if ( p >= tr[dim(tr)[1],2] ) { - tmp = tr[dim(tr)[1],] - tmp[2] = p - collect = rbind(collect, tmp) - done = TRUE - } else { - index = index + 1 - } } + if (p<=tr[1,2]) { + tmp = tr[index,] + tmp[2] = p + collect = rbind(collect, tmp) + } else if (p>=tr[endpoint,2]) { + tmp = tr[endpoint,] + tmp[2] = p + collect = rbind(collect, tmp) + } else { + for (i in seq(index,endpoint)-1) { + if (p >= tr[i,2] && p 0] -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) %dopar% { +all_min_points = foreach(rtt=all_runtypetables,.combine = cbind) %do% { 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) 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)) @@ -167,10 +187,13 @@ yhigh=max(one_frame[typenames],worst_case) typenames = typenames[which(!endsWith(typenames, "_min"))] typenames = typenames[which(!endsWith(typenames, "_max"))] -ml2lines <- function(ml) { +ml2lines <- function(ml,lim) { lines = NULL last = 0 for (i in seq_len(dim(ml)[1])) { + if (!CONTINUE_LINE_TO_END && lim