From c404037d4919c0a3d0f1e5899dcb6c2f90d33cde Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Fri, 25 Apr 2025 10:41:35 +0000 Subject: [PATCH] plot styling --- fuzzers/FRET/benchmark/plot_sqlite.r | 106 +++++++++++++++++++++------ 1 file changed, 82 insertions(+), 24 deletions(-) diff --git a/fuzzers/FRET/benchmark/plot_sqlite.r b/fuzzers/FRET/benchmark/plot_sqlite.r index 3c801fbdf9..67c3a16d9f 100644 --- a/fuzzers/FRET/benchmark/plot_sqlite.r +++ b/fuzzers/FRET/benchmark/plot_sqlite.r @@ -1,12 +1,25 @@ library("mosaic") library("dplyr") library("DBI") +library("tikzDevice") # Add this line to include the tikzDevice library +library("colorspace") +library("heatmaply") +library("RColorBrewer") args = commandArgs(trailingOnly=TRUE) +TOOL_TRANSLATION <- list( + feedgeneration100 = "evolution", + frafl = "coverage", + random = "random", + stgwoet = "FRET" +) + + KNOWN_WCRT <- list( - waters_seq_bytes=219542, # via INSERT_WC - waters_seq_int=219542, # via INSERT_WC + manual interrupt + waters_seq_bytes=212252, # via INSERT_WC + waters_seq_int=0, # via INSERT_WC + manual interrupt + #waters_seq_int=219542, # via INSERT_WC + manual interrupt waters_seq_full=219542,# via INSERT_WC + manual interrupt waters_seq_unsync_full=234439,# via INSERT_WC + manual interrupt polycopter_seq_dataflow_full=343493, # via INSERT_WC + manual interrupt @@ -15,15 +28,48 @@ KNOWN_WCRT <- list( release_seq_full=645885 # via INSERT_WC + manual interrupt ) +# STATIC_WCRT <- list( +# waters_seq_bytes=256632, +# waters_seq_int=256632, +# waters_seq_full=256632, +# waters_seq_unsync_full=272091, +# polycopter_seq_dataflow_full=373628, +# polycopter_seq_dataflow_int=373628, +# release_seq_int=921360, +# release_seq_full=921360 +# ) + STATIC_WCRT <- list( - waters_seq_bytes=256632, - waters_seq_int=256632, - waters_seq_full=256632, - waters_seq_unsync_full=272091, - polycopter_seq_dataflow_full=373628, - polycopter_seq_dataflow_int=373628, - release_seq_int=921360, - release_seq_full=921360 + waters_seq_bytes=0, + waters_seq_int=0, + waters_seq_full=0, + waters_seq_unsync_full=0, + polycopter_seq_dataflow_full=0, + polycopter_seq_dataflow_int=0, + release_seq_int=0, + release_seq_full=0 + ) + +MIN_Y <- list( + waters_seq_bytes=5250, + waters_seq_int=6000, + waters_seq_full=5250, + waters_seq_unsync_full=0, + polycopter_seq_dataflow_full=4000, + polycopter_seq_dataflow_int=4000, + release_seq_int=16500, + release_seq_full=16000 + ) + +LEG_POS <- list( + waters_seq_bytes="bottomright", + waters_seq_int="bottomright", + waters_seq_full="bottomright", + waters_seq_unsync_full="bottomright", + polycopter_seq_dataflow_full="bottomright", + polycopter_seq_dataflow_int="bottomright", + release_seq_int="bottomright", + release_seq_full="bottomright" ) # Read the first command line argument as an sqlite file @@ -52,9 +98,15 @@ ml2lines <- function(ml, casename) { return(lines) } +BREW=RdYlGn(4) +# BREW=Spectral(4) + draw_plot <- function(data, casename) { - MY_COLORS <- c("green", "blue", "red", "magenta", "orange", "cyan", "pink", "gray", "orange", "black", "yellow","brown") - LEGEND_POS="bottomright" + # evo, cov, random, fret + MY_COLORS <- c(BREW[[3]], BREW[[2]], BREW[[1]], BREW[[4]], "cyan", "pink", "gray", "orange", "black", "yellow","brown") + # MY_COLORS <- c("orange", "blue", "red", "green", "orange", "cyan", "pink", "gray", "orange", "black", "yellow","brown") + # MY_COLORS <- c("green", "blue", "red", "magenta", "orange", "cyan", "pink", "gray", "orange", "black", "yellow","brown") + LEGEND_POS=LEG_POS[[casename]] ISNS_PER_US = (10**3)/(2**5) @@ -83,47 +135,53 @@ draw_plot <- function(data, casename) { # draw limits max_x <- max(sapply(data, function(tbl) max(tbl$timestamp, na.rm = TRUE))) + max_x <- min(max_x, 16) # quick fix, cap to 16h max_y <- max(wcrt,max(sapply(data, function(tbl) max(tbl$max, na.rm = TRUE)))) min_y <- min(sapply(data, function(tbl) min(tbl$min, na.rm = TRUE))) + min_y <- max(min_y, MIN_Y[[casename]]) # draw static wcrt max_y <- max(max_y, static_wcrt) # plot setup - h_ = 380 + h_ = 300 w_ = h_*4/3 - png(file=sprintf("%s/sql_%s.png", args[2],casename), width=w_, height=h_) + # png(file=sprintf("%s/sql_%s.png", args[2],casename), width=w_, height=h_) # Modify this line to use tikzDevice + # tikz(file=sprintf("%s/sql_%s.tex", args[2],casename), width=w_/72, height=h_/72) # Modify this line to use tikzDevice + # png(file=sprintf("%s/sql_%s_wide.png", args[2],casename), width=w_*2, height=h_) # Modify this line to use tikzDevice + tikz(file=sprintf("%s/sql_%s_wide.tex", args[2],casename), width=(w_*2)/72, height=h_/72) # Modify this line to use tikzDevice par(mar=c(4,4,1,1)) par(oma=c(0,0,0,0)) - plot(c(0,max_x),c(min_y,max_y), col='white', xlab="Time [h]", ylab="WCRT estimate [us]", pch='.') + plot(c(0,max_x),c(min_y,max_y), col='white', xlab="Time [h]", ylab="WCRT estimate [µs]", pch='.') # plot data for (n in seq_len(length(data))) { d <- data[[n]] malines = ml2lines(d[c('max','timestamp')]) - lines(malines, col=MY_COLORS[[n]], lty='dashed') + lines(malines, col=MY_COLORS[[n]], lty='solid', lwd=2) # Increase line width medlines = ml2lines(d[c('median','timestamp')]) - lines(medlines, col=MY_COLORS[[n]], lty='solid') - milines = ml2lines(d[c('min','timestamp')]) - lines(milines, col=MY_COLORS[[n]], lty='dashed') + lines(medlines, col=MY_COLORS[[n]], lty='dashed', lwd=2) # Increase line width + # milines = ml2lines(d[c('min','timestamp')]) + # lines(milines, col=MY_COLORS[[n]], lty='dashed', lwd=2) # Increase line width } - legend_names <- names(data) - legend_colors <- c(MY_COLORS[1:length(data)],"black","black") + legend_names <- sapply(names(data), function(n) TOOL_TRANSLATION[[n]]) + legend_colors <- c(MY_COLORS[1:length(data)],"grey","grey") legend_styles <- c(rep("solid",length(data)),"dotted","dashed") if (wcrt > 0) { - abline(h=wcrt, col='black', lty='dotted') + abline(h=wcrt, col='grey', lty='dotted', lwd=3) legend_names <- c(legend_names, "WCRT") } if (static_wcrt > 0) { - abline(h=static_wcrt, col='black', lty='dashed') + abline(h=static_wcrt, col='grey', lty='dashed', lwd=3) legend_names <- c(legend_names, "static bound") } legend(LEGEND_POS, legend=legend_names,#"bottomright", col=legend_colors, - lty=legend_styles) + lty=legend_styles, + lwd=2) par(las = 2, mar = c(10, 5, 1, 1)) dev.off()