From e0fbbe32a68783d93b0fd8aaf48b56f6b035db06 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Tue, 23 Feb 2021 12:13:52 +0100 Subject: [PATCH] saiph: update granularity experiment and R script --- garlic/fig/saiph/granularity.R | 14 +-- garlic/fig/saiph/granularityPerNumBlocks.R | 100 +++++++++++++++++++++ 2 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 garlic/fig/saiph/granularityPerNumBlocks.R diff --git a/garlic/fig/saiph/granularity.R b/garlic/fig/saiph/granularity.R index ba093a8..d3ed00d 100644 --- a/garlic/fig/saiph/granularity.R +++ b/garlic/fig/saiph/granularity.R @@ -42,7 +42,7 @@ png("box.png", width=w*ppi, height=h*ppi, res=ppi) p = ggplot(data=D, aes(x=nby, y=tnorm, color=bad)) + # Labels - labs(x="nby", y="Normalized time", + labs(x="nb{y-z}", y="Normalized time", title=sprintf("Saiph-Heat3D normalized time"), subtitle=input_file) + @@ -82,16 +82,16 @@ png("scatter.png", width=w*ppi, height=h*ppi, res=ppi) ## Create the plot with the normalized time vs nblocks p = ggplot(D, aes(x=nby, y=time)) + - labs(x="nby", y="Time (s)", - title=sprintf("Saiph-Heat3D granularity"), - subtitle=input_file) + + labs(x="nb{y-z}", y="Time (s)", + title=sprintf("Saiph-Heat3D granularity"), + subtitle=input_file) + theme_bw() + theme(plot.subtitle=element_text(size=8)) + theme(legend.position = c(0.5, 0.88)) + - geom_point(shape=21, size=3) + - #scale_x_continuous(trans=log2_trans()) + - scale_y_continuous(trans=log2_trans()) + geom_point(shape=21, size=3) + #+ scale_x_continuous(trans=log2_trans()) + #+ scale_y_continuous(trans=log2_trans()) # Render the plot print(p) diff --git a/garlic/fig/saiph/granularityPerNumBlocks.R b/garlic/fig/saiph/granularityPerNumBlocks.R new file mode 100644 index 0000000..4e28f1d --- /dev/null +++ b/garlic/fig/saiph/granularityPerNumBlocks.R @@ -0,0 +1,100 @@ +library(ggplot2) +library(dplyr) +library(scales) +library(jsonlite) + +args=commandArgs(trailingOnly=TRUE) + +# Read the timetable from args[1] +input_file = "nov24Gran.json" +if (length(args)>0) { input_file = args[1] } + +# Load the dataset in NDJSON format +dataset = jsonlite::stream_in(file(input_file)) %>% + jsonlite::flatten() + + +# We only need the nblocks and time +df = select(dataset, config.nby, time) %>% + rename(nby=config.nby) + +df$nby = as.factor(df$nby) + +# Normalize the time by the median +D=group_by(df, nby) %>% + mutate(tnorm = time / median(time) - 1) %>% + mutate(bad = max(ifelse(abs(tnorm) >= 0.01, 1, 0))) + +D$bad = as.factor(D$bad) + + +print(D) + +ppi=300 +h=5 +w=5 + +png("box.png", width=w*ppi, height=h*ppi, res=ppi) +# +# +# +# Create the plot with the normalized time vs nblocks +p = ggplot(data=D, aes(x=nby, y=tnorm, color=bad)) + + + # Labels + labs(x="nb{y-z}", y="Normalized time", + title=sprintf("Saiph-Heat3D normalized time"), + subtitle=input_file) + + + # Center the title + #theme(plot.title = element_text(hjust = 0.5)) + + + # Black and white mode (useful for printing) + #theme_bw() + + + # Add the maximum allowed error lines + geom_hline(yintercept=c(-0.01, 0.01), + linetype="dashed", color="gray") + + + # Draw boxplots + geom_boxplot() + + scale_color_manual(values=c("black", "brown")) + + + #scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) + + + theme_bw() + + + theme(plot.subtitle=element_text(size=8)) + + theme(legend.position = "none") + #theme(legend.position = c(0.85, 0.85)) + + + + +# Render the plot +print(p) + +## Save the png image +dev.off() +# +png("scatter.png", width=w*ppi, height=h*ppi, res=ppi) +# +## Create the plot with the normalized time vs nblocks +p = ggplot(D, aes(x=nby, y=time)) + + + labs(x="nb{y-z}", y="Time (s)", + title=sprintf("Saiph-Heat3D granularity"), + subtitle=input_file) + + theme_bw() + + theme(plot.subtitle=element_text(size=8)) + + theme(legend.position = c(0.5, 0.88)) + + + geom_point(shape=21, size=3) + + #scale_x_continuous(trans=log2_trans()) + + scale_y_continuous(trans=log2_trans()) + +# Render the plot +print(p) + +# Save the png image +dev.off()