bscpkgs/garlic/fig/nbody/ss.R

66 lines
2.2 KiB
R
Raw Normal View History

2021-03-26 18:16:17 +01:00
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(scales)
library(jsonlite)
library(viridis, warn.conflicts = FALSE)
# Load the arguments (argv)
args = commandArgs(trailingOnly=TRUE)
if (length(args)>0) { input_file = args[1] } else { input_file = "input" }
df = jsonlite::stream_in(file(input_file), verbose=FALSE) %>%
jsonlite::flatten() %>%
2021-04-20 17:16:17 +02:00
select(config.blocksize, config.gitBranch, config.nodes, unit, time) %>%
rename(nodes = config.nodes, blocksize=config.blocksize, branch=config.gitBranch) %>%
mutate(time.nodes = time * nodes) %>%
2021-03-26 18:16:17 +01:00
mutate(blocksize = as.factor(blocksize)) %>%
mutate(nodes = as.factor(nodes)) %>%
mutate(branch = as.factor(branch)) %>%
mutate(unit = as.factor(unit)) %>%
group_by(unit) %>%
mutate(median.time = median(time)) %>%
2021-04-20 17:16:17 +02:00
mutate(median.time.nodes = median(time.nodes)) %>%
2021-03-26 18:16:17 +01:00
mutate(normalized.time = time / median.time - 1) %>%
mutate(log.median.time = log(median.time)) %>%
ungroup()
dpi = 300
h = 5
w = 8
# ---------------------------------------------------------------------
p = ggplot(df, aes(x=nodes, y=normalized.time, color=branch)) +
geom_boxplot() +
geom_hline(yintercept=c(-0.01, 0.01), linetype="dashed", color="red") +
facet_wrap(~ branch) +
theme_bw() +
labs(x="Nodes", y="Normalized time (s)", title="NBody Scaling: Normalized Time",
subtitle=input_file) +
theme(plot.subtitle=element_text(size=5)) +
theme(legend.position="bottom") +
theme(legend.text = element_text(size=7))
ggsave("normalized.time.png", plot=p, width=w, height=h, dpi=dpi)
ggsave("normalized.time.pdf", plot=p, width=w, height=h, dpi=dpi)
# ---------------------------------------------------------------------
2021-04-20 17:16:17 +02:00
p = ggplot(df, aes(x=nodes, y=time.nodes, color=branch)) +
2021-03-26 18:16:17 +01:00
geom_point(shape=21, size=3) +
2021-04-20 17:16:17 +02:00
geom_line(aes(y=median.time.nodes, group=branch)) +
2021-03-26 18:16:17 +01:00
theme_bw() +
2021-04-20 17:16:17 +02:00
labs(x="Nodes", y="Time * nodes (s)", title="NBody Scaling: Time * nodes",
2021-03-26 18:16:17 +01:00
subtitle=input_file) +
theme(plot.subtitle=element_text(size=5)) +
theme(legend.position="bottom") +
theme(legend.text = element_text(size=7))
2021-04-20 17:16:17 +02:00
ggsave("time.nodes.png", plot=p, width=w, height=h, dpi=dpi)
ggsave("time.nodes.pdf", plot=p, width=w, height=h, dpi=dpi)