Update charts to account for new datafile/charts folders
This commit is contained in:
@@ -4,7 +4,7 @@ library(readr)
|
||||
library(stringr)
|
||||
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
|
||||
# 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%.
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 2) {
|
||||
stop("Need at least 2 experiments")
|
||||
}
|
||||
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[length(args)]
|
||||
} else {
|
||||
"resultsdata.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
tail_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[-length(args)]
|
||||
} else {
|
||||
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) {
|
||||
dir_name <- basename(path)
|
||||
match <- str_match(
|
||||
@@ -58,7 +66,7 @@ for (arg in exp_args) {
|
||||
next
|
||||
}
|
||||
|
||||
csv_file <- file.path(info$path, csv_suffix)
|
||||
csv_file <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
|
||||
if (!file.exists(csv_file)) {
|
||||
warning(paste("Missing:", csv_file))
|
||||
next
|
||||
@@ -120,5 +128,9 @@ plot <- ggplot(
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user