Update charts to account for new datafile/charts folders

This commit is contained in:
2026-09-18 19:57:13 +02:00
parent 731701c991
commit a3e341cf27
12 changed files with 200 additions and 83 deletions
@@ -3,26 +3,34 @@ library(dplyr)
library(readr) library(readr)
library(stringr) library(stringr)
# Usage: Rscript combined_comparison.r exp_abspath1 exp_abspath2 ... [resultsdata_file] # Usage: Rscript combined_fault_count_comparison.r exp1 exp2 ... queries_dir charts_dir [resultsdata_file]
# One coordinate system per base experiment (facet); c/aot/interp variants # One coordinate system per base experiment (facet); c/aot/interp variants
# share each facet, coloured by variant. # share each facet, coloured by variant.
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
stop("Need at least 1 experiment")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)] args[length(args)]
} else { } else {
"resultsdata.csv" "resultsdata.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 3) {
stop(paste(
"Usage: combined_fault_count_comparison.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [resultsdata_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
extract_info <- function(path) { extract_info <- function(path) {
dir_name <- basename(path) dir_name <- basename(path)
match <- str_match( match <- str_match(
@@ -44,7 +52,7 @@ for (arg in exp_args) {
next next
} }
csv_file <- file.path(info$path, csv_suffix) csv_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
if (!file.exists(csv_file)) { if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file)) warning(paste("Missing:", csv_file))
next next
@@ -98,6 +106,10 @@ plot <- ggplot(
) )
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix) suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/fault_count_comparison", suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
outfile <- file.path(
charts_dir,
paste0("fault_count_comparison", suffix, ".svg")
)
ggsave(outfile, plot = plot, width = 12, height = 6) ggsave(outfile, plot = plot, width = 12, height = 6)
print(paste("Saved", outfile)) print(paste("Saved", outfile))
@@ -4,25 +4,33 @@ library(readr)
library(stringr) library(stringr)
library(tidyr) library(tidyr)
# Usage: Rscript combined_fault_correlation.r exp_abspath1 exp_abspath2 ... [resultsdata_file] # Usage: Rscript combined_fault_count_correlation.r exp1 exp2 ... queries_dir charts_dir [resultsdata_file]
# Plots correlation between raw aot and interp fault counts (no C baseline). # Plots correlation between raw aot and interp fault counts (no C baseline).
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
stop("Need at least 2 experiments")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)] args[length(args)]
} else { } else {
"resultsdata.csv" "resultsdata.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 4) {
stop(paste(
"Usage: combined_fault_count_correlation.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [resultsdata_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
extract_info <- function(path) { extract_info <- function(path) {
dir_name <- basename(path) dir_name <- basename(path)
match <- str_match( match <- str_match(
@@ -44,7 +52,7 @@ for (arg in exp_args) {
next next
} }
csv_file <- file.path(info$path, csv_suffix) csv_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
if (!file.exists(csv_file)) { if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file)) warning(paste("Missing:", csv_file))
next next
@@ -123,6 +131,10 @@ plot <- ggplot(
) )
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix) suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/fault_count_correlation", suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
outfile <- file.path(
charts_dir,
paste0("fault_count_correlation", suffix, ".svg")
)
ggsave(outfile, plot = plot, width = 10, height = 8) ggsave(outfile, plot = plot, width = 10, height = 8)
print(paste("Saved", outfile)) print(paste("Saved", outfile))
+19 -7
View File
@@ -4,7 +4,7 @@ library(readr)
library(stringr) library(stringr)
library(tidyr) library(tidyr)
# Usage: Rscript combined_fault_probability.r exp_abspath1 ... resultsdata_file # Usage: Rscript combined_fault_probability.r exp1 exp2 ... queries_dir charts_dir [resultsdata_file]
# #
# Divides by the faultspace area instead of by a marker total, which makes the # Divides by the faultspace area instead of by a marker total, which makes the
# running modes comparable: raw counts scale with how long WAMR runs, so they # running modes comparable: raw counts scale with how long WAMR runs, so they
@@ -17,21 +17,29 @@ library(tidyr)
# was therefore this chart with every bar rescaled to 100%. # was therefore this chart with every bar rescaled to 100%.
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
stop("Need at least 2 experiments")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)] args[length(args)]
} else { } else {
"resultsdata.csv" "resultsdata.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 4) {
stop(paste(
"Usage: combined_fault_probability.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [resultsdata_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
extract_info <- function(path) { extract_info <- function(path) {
dir_name <- basename(path) dir_name <- basename(path)
match <- str_match( match <- str_match(
@@ -58,7 +66,7 @@ for (arg in exp_args) {
next next
} }
csv_file <- file.path(info$path, csv_suffix) csv_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
if (!file.exists(csv_file)) { if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file)) warning(paste("Missing:", csv_file))
next next
@@ -120,5 +128,9 @@ plot <- ggplot(
) )
out_suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix) out_suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
filename <- paste0("injections/fault_probability", out_suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
filename <- file.path(
charts_dir,
paste0("fault_probability", out_suffix, ".svg")
)
ggsave(filename, plot = plot, width = 13, height = 8) ggsave(filename, plot = plot, width = 13, height = 8)
@@ -4,24 +4,32 @@ library(readr)
library(stringr) library(stringr)
library(tidyr) library(tidyr)
# Usage: Rscript combined_fault_probability_merged.r exp_abspath1 ... resultsdata_file # Usage: Rscript combined_fault_probability_merged.r exp1 exp2 ... queries_dir charts_dir [resultsdata_file]
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
stop("Need at least 2 experiments")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)] args[length(args)]
} else { } else {
"resultsdata.csv" "resultsdata.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 4) {
stop(paste(
"Usage: combined_fault_probability_merged.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [resultsdata_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
extract_info <- function(path) { extract_info <- function(path) {
dir_name <- basename(path) dir_name <- basename(path)
match <- str_match( match <- str_match(
@@ -48,7 +56,7 @@ for (arg in exp_args) {
next next
} }
csv_file <- file.path(info$path, csv_suffix) csv_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
if (!file.exists(csv_file)) { if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file)) warning(paste("Missing:", csv_file))
next next
@@ -113,5 +121,9 @@ plot <- ggplot(
) )
out_suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix) out_suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
filename <- paste0("injections/fault_probability_merged", out_suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
filename <- file.path(
charts_dir,
paste0("fault_probability_merged", out_suffix, ".svg")
)
ggsave(filename, plot = plot, width = 13, height = 8) ggsave(filename, plot = plot, width = 13, height = 8)
@@ -3,30 +3,38 @@ library(dplyr)
library(readr) library(readr)
library(stringr) library(stringr)
# Usage: Rscript combined_fault_rates.r exp_abspath1 exp_abspath2 ... [faults_file] # Usage: Rscript combined_fault_rates_per_instruction.r exp1 exp2 ... queries_dir charts_dir [faults_file]
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
stop("Need at least 1 experiment")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)] args[length(args)]
} else { } else {
"faults.csv" "faults.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 3) {
stop(paste(
"Usage: combined_fault_rates_per_instruction.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [faults_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
# Faults / instruction count, per experiment # Faults / instruction count, per experiment
rates <- data.frame() rates <- data.frame()
for (arg in exp_args) { for (arg in exp_args) {
faults_file <- file.path(arg, csv_suffix) faults_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
mnem_file <- file.path(arg, "mnemonics.csv") mnem_file <- file.path(queries_dir, paste0(arg, "_mnemonics.csv"))
if (!file.exists(faults_file)) { if (!file.exists(faults_file)) {
warning(paste("Missing:", faults_file)) warning(paste("Missing:", faults_file))
@@ -110,6 +118,10 @@ plot <- ggplot(
) )
suffix <- gsub("^faults|\\.csv$", "", csv_suffix) suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/fault_rates_per_instruction", suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
outfile <- file.path(
charts_dir,
paste0("fault_rates_per_instruction", suffix, ".svg")
)
ggsave(outfile, plot = plot, width = 12, height = 6) ggsave(outfile, plot = plot, width = 12, height = 6)
print(paste("Saved", outfile)) print(paste("Saved", outfile))
@@ -2,12 +2,9 @@ library(ggplot2)
library(dplyr) library(dplyr)
library(readr) library(readr)
# Usage: Rscript combined_instr_fault_correlation.r exp_abspath1 exp_abspath2 ... [faults_file] # Usage: Rscript combined_instr_fault_correlation.r exp1 exp2 ... queries_dir charts_dir [faults_file]
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
stop("Need at least 1 experiment")
}
# TODO: I should probably stop duplicating this each time # TODO: I should probably stop duplicating this each time
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
@@ -15,12 +12,23 @@ csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
} else { } else {
"faults.csv" "faults.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 3) {
stop(paste(
"Usage: combined_instr_fault_correlation.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [faults_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
# Don't use counts from faults.csv, as that would correlate completely # Don't use counts from faults.csv, as that would correlate completely
# because only mnemonics with faults are listed there # because only mnemonics with faults are listed there
# NOTE: Doesn't match selected filters for faults.csv # NOTE: Doesn't match selected filters for faults.csv
@@ -31,8 +39,8 @@ faults_data <- data.frame()
# TODO: I should probably stop duplicating this each time # TODO: I should probably stop duplicating this each time
for (arg in exp_args) { for (arg in exp_args) {
mnem_path <- file.path(arg, mnemonics_file) mnem_path <- file.path(queries_dir, paste0(arg, "_", mnemonics_file))
faults_path <- file.path(arg, csv_suffix) faults_path <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
if (!file.exists(mnem_path)) { if (!file.exists(mnem_path)) {
warning(paste("Missing:", mnem_path)) warning(paste("Missing:", mnem_path))
@@ -129,6 +137,10 @@ plot <- ggplot(
) )
suffix <- gsub("^faults|\\.csv$", "", csv_suffix) suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/instr_fault_correlation", suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
outfile <- file.path(
charts_dir,
paste0("instr_fault_correlation", suffix, ".svg")
)
ggsave(outfile, plot = plot, width = 10, height = 8) ggsave(outfile, plot = plot, width = 10, height = 8)
print(paste("Saved", outfile)) print(paste("Saved", outfile))
+16 -7
View File
@@ -3,25 +3,33 @@ library(dplyr)
library(readr) library(readr)
library(stringr) library(stringr)
# Usage: Rscript ratio_comparison.r exp_abspath1 exp_abspath2 ... [resultsdata_file] # Usage: Rscript combined_ratio_comparison.r exp1 exp2 ... queries_dir charts_dir [resultsdata_file]
# Plots every benchmark separately # Plots every benchmark separately
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
stop("Need at least 2 experiments")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)] args[length(args)]
} else { } else {
"resultsdata.csv" "resultsdata.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 4) {
stop(paste(
"Usage: combined_ratio_comparison.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [resultsdata_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
extract_info <- function(path) { extract_info <- function(path) {
dir_name <- basename(path) dir_name <- basename(path)
match <- str_match( match <- str_match(
@@ -43,7 +51,7 @@ for (arg in exp_args) {
next next
} }
csv_file <- file.path(info$path, csv_suffix) csv_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
if (!file.exists(csv_file)) { if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file)) warning(paste("Missing:", csv_file))
next next
@@ -99,6 +107,7 @@ plot <- ggplot(
) )
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix) suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/ratio_comparison", suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
outfile <- file.path(charts_dir, paste0("ratio_comparison", suffix, ".svg"))
ggsave(outfile, plot = plot, width = 12, height = 8) ggsave(outfile, plot = plot, width = 12, height = 8)
print(paste("Saved", outfile)) print(paste("Saved", outfile))
@@ -3,25 +3,33 @@ library(dplyr)
library(readr) library(readr)
library(stringr) library(stringr)
# Usage: Rscript ratio_comparison_merged_trap.r exp_abspath1 exp_abspath2 ... [resultsdata_file] # Usage: Rscript combined_ratio_comparison_merged.r exp1 exp2 ... queries_dir charts_dir [resultsdata_file]
# Sums all benchmarks, merges GROUP1_MARKER into TRAP # Sums all benchmarks, merges GROUP1_MARKER into TRAP
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
stop("Need at least 2 experiments")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) { csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)] args[length(args)]
} else { } else {
"resultsdata.csv" "resultsdata.csv"
} }
exp_args <- if (grepl("\\.csv$", args[length(args)])) { tail_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)] args[-length(args)]
} else { } else {
args args
} }
if (length(tail_args) < 4) {
stop(paste(
"Usage: combined_ratio_comparison_merged.r",
"<exp1> <exp2> ... <queries_dir> <charts_dir> [resultsdata_file]"
))
}
charts_dir <- tail_args[length(tail_args)]
queries_dir <- tail_args[length(tail_args) - 1]
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
extract_info <- function(path) { extract_info <- function(path) {
dir_name <- basename(path) dir_name <- basename(path)
match <- str_match( match <- str_match(
@@ -43,7 +51,7 @@ for (arg in exp_args) {
next next
} }
csv_file <- file.path(info$path, csv_suffix) csv_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
if (!file.exists(csv_file)) { if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file)) warning(paste("Missing:", csv_file))
next next
@@ -102,7 +110,11 @@ plot <- ggplot(
) )
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix) suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/ratio_comparison_merged_trap", suffix, ".svg") dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
outfile <- file.path(
charts_dir,
paste0("ratio_comparison_merged_trap", suffix, ".svg")
)
ggsave( ggsave(
outfile, outfile,
plot = plot, plot = plot,
+17 -9
View File
@@ -1,21 +1,28 @@
library(ggplot2) library(ggplot2)
library(ggalluvial) library(ggalluvial)
# Usage: Rscript combined_comparion.r exp_abspath1 exp_abspath2 ... # Usage: Rscript combined_sankey.r exp1 exp2 queries_dir charts_dir [faults_file]
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
argc <- length(args) argc <- length(args)
if (argc < 2 || argc > 3) { if (argc < 4 || argc > 5) {
print("Expecting two or three arguments: exp1 exp2 [faults_file]") print(paste(
"Expecting four or five arguments:",
"exp1 exp2 queries_dir charts_dir [faults_file]"
))
stop() stop()
} }
faults_file <- if (argc == 3) args[3] else "faults.csv" faults_file <- if (argc == 5) args[5] else "faults.csv"
suffix <- gsub("^faults|\\.csv$", "", faults_file) suffix <- gsub("^faults|\\.csv$", "", faults_file)
for (experiment in args[1:2]) { experiments <- args[1:2]
datafile <- file.path(experiment, faults_file) queries_dir <- args[3]
charts_dir <- args[4]
for (experiment in experiments) {
datafile <- file.path(queries_dir, paste0(experiment, "_", faults_file))
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
print(paste("Input file", datafile, "is missing")) print(paste("Input file", datafile, "is missing"))
stop() stop()
@@ -33,13 +40,13 @@ resulttype_labels <- c(
) )
# Read data # Read data
datafile1 <- file.path(args[1], faults_file) datafile1 <- file.path(queries_dir, paste0(experiments[1], "_", faults_file))
data1 <- readr::read_csv(datafile1) data1 <- readr::read_csv(datafile1)
data1$fault_address <- strtoi(data1$fault_address) data1$fault_address <- strtoi(data1$fault_address)
data1$resulttype <- resulttype_labels[data1$resulttype] data1$resulttype <- resulttype_labels[data1$resulttype]
# tibble::glimpse(data1) # tibble::glimpse(data1)
datafile2 <- file.path(args[2], faults_file) datafile2 <- file.path(queries_dir, paste0(experiments[2], "_", faults_file))
data2 <- readr::read_csv(datafile2) data2 <- readr::read_csv(datafile2)
data2$fault_address <- strtoi(data2$fault_address) data2$fault_address <- strtoi(data2$fault_address)
data2$resulttype <- resulttype_labels[data2$resulttype] data2$resulttype <- resulttype_labels[data2$resulttype]
@@ -77,7 +84,8 @@ plot <- ggplot(
theme(legend.position = "none") theme(legend.position = "none")
# TODO: Name the file according to the benchmarks # TODO: Name the file according to the benchmarks
dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
ggsave( ggsave(
paste0(args[2], "/../sankey", suffix, ".svg"), file.path(charts_dir, paste0("sankey", suffix, ".svg")),
plot = plot, plot = plot,
) )
+17 -8
View File
@@ -4,7 +4,7 @@ library(dplyr) # filter, mutate
library(tidyr) # complete library(tidyr) # complete
library(scales) library(scales)
# Usage: Rscript single_heatmap.r exp_abspath # Usage: Rscript single_heatmap.r exp_name queries_dir charts_dir archive_dir [faults_file]
# ============================================================================= # =============================================================================
# CONFIG # CONFIG
@@ -127,19 +127,27 @@ n_occupied_rows <- function(addr_ints, rw) {
# ============================================================================= # =============================================================================
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) { if (length(args) < 4) {
stop("Usage: Rscript single_heatmap.r <experiment_dir>") stop(paste(
"Usage: Rscript single_heatmap.r",
"<experiment> <queries_dir> <charts_dir> <archive_dir> [faults_file]"
))
} }
experiment <- args[1] experiment <- args[1]
faults_file <- if (length(args) >= 2) args[2] else "faults.csv" queries_dir <- args[2]
charts_dir <- args[3]
archive_dir <- args[4]
faults_file <- if (length(args) >= 5) args[5] else "faults.csv"
suffix <- gsub("^faults|\\.csv$", "", faults_file) suffix <- gsub("^faults|\\.csv$", "", faults_file)
dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
# ============================================================================= # =============================================================================
# INPUT DATA (read once) # INPUT DATA (read once)
# ============================================================================= # =============================================================================
datafile <- file.path(experiment, faults_file) datafile <- file.path(queries_dir, paste0(experiment, "_", faults_file))
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
stop(paste("Input file not found:", datafile)) stop(paste("Input file not found:", datafile))
} }
@@ -161,7 +169,7 @@ raw <- read_csv(
# Names vector: sym_addr["_text_start"] = 0x10001a # Names vector: sym_addr["_text_start"] = 0x10001a
sym_addr <- setNames(integer(0), character(0)) sym_addr <- setNames(integer(0), character(0))
elf_file <- file.path(experiment, "system.elf") elf_file <- file.path(archive_dir, experiment, "system.elf")
if (!file.exists(elf_file)) { if (!file.exists(elf_file)) {
message("system.elf not found") message("system.elf not found")
@@ -483,9 +491,10 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
fig_h <- total_slots * tile_size + 2.5 fig_h <- total_slots * tile_size + 2.5
outfile <- file.path( outfile <- file.path(
experiment, charts_dir,
paste0( paste0(
"heatmap_", experiment,
"_heatmap_",
target_resulttype, target_resulttype,
"_", "_",
target_benchmark, target_benchmark,
+8 -4
View File
@@ -1,12 +1,15 @@
library(ggplot2) library(ggplot2)
# Usage: Rscript single_result.r exp_abspath [resultsdata_file] # Usage: Rscript single_result.r exp_name queries_dir charts_dir [resultsdata_file]
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
experiment <- args[1] experiment <- args[1]
resultsdata_file <- if (length(args) >= 2) args[2] else "resultsdata.csv" queries_dir <- args[2]
charts_dir <- args[3]
resultsdata_file <-
if (length(args) >= 4) args[4] else "resultsdata.csv"
suffix <- gsub("^resultsdata|\\.csv$", "", resultsdata_file) suffix <- gsub("^resultsdata|\\.csv$", "", resultsdata_file)
datafile <- file.path(experiment, resultsdata_file) datafile <- file.path(queries_dir, paste0(experiment, "_", resultsdata_file))
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
print(paste("Input file", datafile, "is missing")) print(paste("Input file", datafile, "is missing"))
@@ -22,7 +25,8 @@ plot <- ggplot(data, aes(x = benchmark, y = faults, fill = resulttype)) +
labs(x = "Benchmark", y = "Faults", fill = "Result Type") + labs(x = "Benchmark", y = "Faults", fill = "Result Type") +
theme_minimal() theme_minimal()
dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
ggsave( ggsave(
paste0(experiment, "/single_result", suffix, ".svg"), file.path(charts_dir, paste0(experiment, "_single_result", suffix, ".svg")),
plot = plot, plot = plot,
) )
+7 -4
View File
@@ -1,14 +1,16 @@
library(ggplot2) library(ggplot2)
# Usage: Rscript single_scatter.r exp_abspath # Usage: Rscript single_scatter.r exp_name queries_dir charts_dir [faults_file]
# TODO: Allow filtering resulttypes (or at least exclude OK_MARKER) # TODO: Allow filtering resulttypes (or at least exclude OK_MARKER)
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
experiment <- args[1] experiment <- args[1]
faults_file <- if (length(args) >= 2) args[2] else "faults.csv" queries_dir <- args[2]
charts_dir <- args[3]
faults_file <- if (length(args) >= 4) args[4] else "faults.csv"
suffix <- gsub("^faults|\\.csv$", "", faults_file) suffix <- gsub("^faults|\\.csv$", "", faults_file)
datafile <- file.path(experiment, faults_file) datafile <- file.path(queries_dir, paste0(experiment, "_", faults_file))
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
print(paste("Input file", datafile, "is missing")) print(paste("Input file", datafile, "is missing"))
@@ -28,7 +30,8 @@ plot <- ggplot(data, aes(x = fault_address, y = faults)) +
labs(x = "Address", y = "Faults", color = "Type") + labs(x = "Address", y = "Faults", color = "Type") +
theme_minimal() theme_minimal()
dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
ggsave( ggsave(
paste0(experiment, "/scatter", suffix, ".svg"), file.path(charts_dir, paste0(experiment, "_scatter", suffix, ".svg")),
plot = plot, plot = plot,
) )