From 0a233aad48766bcc422d45c0d8fb3bd68331d88e Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Thu, 14 Nov 2024 13:22:04 +0100 Subject: [PATCH] plot stgsize + observe_hitcounts-- --- fuzzers/FRET/Cargo.toml | 2 +- fuzzers/FRET/benchmark/Snakefile | 2 +- fuzzers/FRET/benchmark/plot_all_stgsizes.sh | 20 +++++++++++++ fuzzers/FRET/benchmark/plot_stgsize.r | 23 ++++++++++++++ fuzzers/FRET/benchmark/plot_stgsize_multi.r | 33 +++++++++++++++++++++ 5 files changed, 78 insertions(+), 2 deletions(-) create mode 100755 fuzzers/FRET/benchmark/plot_all_stgsizes.sh create mode 100755 fuzzers/FRET/benchmark/plot_stgsize.r create mode 100755 fuzzers/FRET/benchmark/plot_stgsize_multi.r diff --git a/fuzzers/FRET/Cargo.toml b/fuzzers/FRET/Cargo.toml index f3566f883e..7c070454bb 100644 --- a/fuzzers/FRET/Cargo.toml +++ b/fuzzers/FRET/Cargo.toml @@ -47,7 +47,7 @@ sched_stg_abbhash = ['sched_stg'] # every path of abbs sched_stg_aggregatehash = ['sched_stg'] # every aggregated path (order independent) # overall_configs config_genetic = ["gensize_100","feed_genetic","sched_genetic","trace_stg"] -config_afl = ["feed_afl","sched_afl","observe_hitcounts","trace_stg"] +config_afl = ["feed_afl","sched_afl","trace_stg"] config_frafl = ["feed_afl","sched_afl","feed_longest","trace_stg"] config_stg = ["feed_stg_aggregatehash","sched_stg_aggregatehash","mutate_stg"] # config_stg_aggregate = ["feed_stg_aggregatehash","sched_stg_aggregatehash","mutate_stg"] diff --git a/fuzzers/FRET/benchmark/Snakefile b/fuzzers/FRET/benchmark/Snakefile index d1c7cd9603..c2b4debc98 100644 --- a/fuzzers/FRET/benchmark/Snakefile +++ b/fuzzers/FRET/benchmark/Snakefile @@ -44,7 +44,7 @@ rule build_afl: output: directory("bins/target_afl") shell: - "cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_afl,observe_hitcounts" + "cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_afl" rule build_stg: input: diff --git a/fuzzers/FRET/benchmark/plot_all_stgsizes.sh b/fuzzers/FRET/benchmark/plot_all_stgsizes.sh new file mode 100755 index 0000000000..60706c3884 --- /dev/null +++ b/fuzzers/FRET/benchmark/plot_all_stgsizes.sh @@ -0,0 +1,20 @@ +get_max_nodecount () { + rm -f sizecomp && for sizefile in remote/timedump/**/$1*.stgsize;do echo "$(tail -n 1 $sizefile),${sizefile}" >> sizecomp; done; sort -n sizecomp | tail -n 1 +} + +get_largest_files () { + T=$(get_max_nodecount $1) + echo $T | cut -d',' -f6 +} + +perform () { + T=$(get_max_nodecount $1) + echo $T | cut -d',' -f6 + echo $T | cut -d',' -f6 | xargs -I {} ./plot_stgsize.r {} + mv "$(echo $T | cut -d',' -f6 | xargs -I {} basename -s .stgsize {})_nodes.png" $1_nodes.png +} + +perform copter +perform release +perform waters +./plot_stgsize_multi.r $(get_largest_files copter) $(get_largest_files release) $(get_largest_files waters) \ No newline at end of file diff --git a/fuzzers/FRET/benchmark/plot_stgsize.r b/fuzzers/FRET/benchmark/plot_stgsize.r new file mode 100755 index 0000000000..7de8a7e8fc --- /dev/null +++ b/fuzzers/FRET/benchmark/plot_stgsize.r @@ -0,0 +1,23 @@ +#!/usr/bin/env Rscript +# Load necessary libraries +library(ggplot2) + +# Define the function to load CSV and plot +plot_stgsize <- function(file_path) { + print(file_path) + # Read the CSV file without headers + data <- read.csv(file_path, header = FALSE) + data['V5'] <- data['V5']/(3600*1000) + + # Plot the line chart + p <- ggplot(data, aes(x = V5, y = V2)) + + geom_line() + + labs(x = "runtime [h]", y = "# of nodes") + #, title = "Number of nodes over time.") + + theme_minimal() + + output_file <- sub("\\.stgsize$", paste0("_nodes.png"), file_path) + ggsave(basename(output_file), plot = p + theme_bw(base_size = 10), width = 3.5, height = 2, dpi = 300, units = "in", device = "png") +} + +args <- commandArgs(trailingOnly = TRUE) +plot_stgsize(args[1]) \ No newline at end of file diff --git a/fuzzers/FRET/benchmark/plot_stgsize_multi.r b/fuzzers/FRET/benchmark/plot_stgsize_multi.r new file mode 100755 index 0000000000..5f621d161e --- /dev/null +++ b/fuzzers/FRET/benchmark/plot_stgsize_multi.r @@ -0,0 +1,33 @@ +#!/usr/bin/env Rscript +library(ggplot2) + +# Function to plot multiple files +plot_multiple_files <- function(file_paths) { + all_data <- data.frame() + + for (file_path in file_paths) { + # Read the CSV file without headers + data <- read.csv(file_path, header = FALSE) + data['V5'] <- data['V5']/(3600*1000) + + # Extract the name for the line + target <- sub("_.*", "", basename(file_path)) + data$target <- target + + # Combine data + all_data <- rbind(all_data, data) + } + + # Plot the line chart + p <- ggplot(all_data, aes(x = V5, y = V2, color = target)) + + geom_line() + + labs(x = "runtime [h]", y = "# of nodes") + + theme_minimal() + + # Save the plot + ggsave("stg_node_sizes.png", plot = p + theme_bw(base_size = 10), width = 4, height = 2.5, dpi = 300, units = "in", device = "png") +} + +# Example usage +file_paths <- commandArgs(trailingOnly = TRUE) +plot_multiple_files(file_paths) \ No newline at end of file