bscpkgs/garlic/fig/heat/granularity.R

68 lines
1.8 KiB
R
Raw Normal View History

2020-11-05 19:56:26 +01:00
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
2020-11-05 19:56:26 +01:00
library(scales)
library(jsonlite)
library(viridis, warn.conflicts = FALSE)
library(stringr)
2020-11-05 19:56:26 +01:00
args = commandArgs(trailingOnly=TRUE)
2020-11-05 19:56:26 +01:00
# Set the input dataset if given in argv[1], or use "input" as default
if (length(args)>0) { input_file = args[1] } else { input_file = "input" }
2020-11-05 19:56:26 +01:00
df = jsonlite::stream_in(file(input_file), verbose=FALSE) %>%
2020-11-05 19:56:26 +01:00
jsonlite::flatten() %>%
2020-11-05 19:56:26 +01:00
select(unit,
config.cbs,
config.rbs,
time,
total_time) %>%
2020-11-05 19:56:26 +01:00
rename(cbs=config.cbs,
rbs=config.rbs) %>%
2020-11-05 19:56:26 +01:00
# Convert to factors
mutate(cbs = as.factor(cbs)) %>%
mutate(rbs = as.factor(rbs)) %>%
mutate(unit = as.factor(unit)) %>%
2020-11-05 19:56:26 +01:00
# Compute median times
group_by(unit) %>%
mutate(median.time = median(time)) %>%
mutate(normalized.time = time / median.time - 1) %>%
mutate(log.median.time = log(median.time)) %>%
ungroup()
2020-11-05 19:56:26 +01:00
dpi = 300
h = 6
w = 6
2020-11-05 19:56:26 +01:00
# ---------------------------------------------------------------------
2020-11-05 19:56:26 +01:00
p = ggplot(df, aes(x=cbs, y=normalized.time)) +
geom_boxplot() +
geom_hline(yintercept=c(-0.01, 0.01), linetype="dashed", color="red") +
theme_bw() +
labs(y="Normalized time",
title="Heat granularity: normalized time",
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8))
2020-11-05 19:56:26 +01:00
ggsave("normalized.time.png", plot=p, width=w, height=h, dpi=dpi)
ggsave("normalized.time.pdf", plot=p, width=w, height=h, dpi=dpi)
2020-11-05 19:56:26 +01:00
# ---------------------------------------------------------------------
2020-11-05 19:56:26 +01:00
p = ggplot(df, aes(x=cbs, y=time)) +
geom_point(shape=21, size=3) +
geom_line(aes(y=median.time, group=0)) +
theme_bw() +
labs(y="Time (s)", title="Heat granularity: time",
subtitle=input_file) +
theme(plot.subtitle=element_text(size=8))
2020-11-05 19:56:26 +01:00
ggsave("time.png", plot=p, width=w, height=h, dpi=dpi)
ggsave("time.pdf", plot=p, width=w, height=h, dpi=dpi)