2020-11-05 19:56:26 +01:00
|
|
|
library(ggplot2)
|
|
|
|
library(dplyr)
|
|
|
|
library(scales)
|
|
|
|
library(jsonlite)
|
|
|
|
|
|
|
|
args=commandArgs(trailingOnly=TRUE)
|
|
|
|
|
|
|
|
# Read the timetable from args[1]
|
|
|
|
input_file = "input.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
|
2021-03-05 16:21:13 +01:00
|
|
|
df = select(dataset, config.cbs, config.rbs, time) %>%
|
|
|
|
rename(cbs=config.cbs, rbs=config.rbs)
|
2020-11-05 19:56:26 +01:00
|
|
|
|
2021-03-05 16:21:13 +01:00
|
|
|
df$cbs = as.factor(df$cbs)
|
|
|
|
df$rbs = as.factor(df$rbs)
|
2020-11-05 19:56:26 +01:00
|
|
|
|
|
|
|
# Normalize the time by the median
|
2021-03-05 16:21:13 +01:00
|
|
|
df=group_by(df, cbs, rbs) %>%
|
|
|
|
mutate(mtime = median(time)) %>%
|
|
|
|
mutate(tnorm = time / mtime - 1) %>%
|
|
|
|
mutate(logmtime = log(mtime)) %>%
|
|
|
|
ungroup() %>%
|
|
|
|
filter(between(mtime, mean(time) - (1 * sd(time)),
|
|
|
|
mean(time) + (1 * sd(time))))
|
2020-11-05 19:56:26 +01:00
|
|
|
|
|
|
|
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
|
2021-03-05 16:21:13 +01:00
|
|
|
p = ggplot(data=df, aes(x=cbs, y=tnorm)) +
|
2020-11-05 19:56:26 +01:00
|
|
|
|
|
|
|
# Labels
|
2021-03-05 16:21:13 +01:00
|
|
|
labs(x="cbs", y="Normalized time",
|
2020-11-05 19:56:26 +01:00
|
|
|
title=sprintf("Heat 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="red") +
|
|
|
|
|
|
|
|
# Draw boxplots
|
|
|
|
geom_boxplot() +
|
|
|
|
|
|
|
|
#scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
|
|
|
|
|
|
|
|
theme_bw() +
|
|
|
|
|
|
|
|
theme(plot.subtitle=element_text(size=8)) +
|
|
|
|
|
|
|
|
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
|
2021-03-05 16:21:13 +01:00
|
|
|
p = ggplot(df, aes(x=cbs, y=time, linetype=rbs, group=rbs)) +
|
2020-11-05 19:56:26 +01:00
|
|
|
|
2021-03-05 16:21:13 +01:00
|
|
|
labs(x="cbs", y="Time (s)",
|
2020-11-05 19:56:26 +01:00
|
|
|
title=sprintf("Heat 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) +
|
2021-03-05 16:21:13 +01:00
|
|
|
geom_line(aes(y=mtime)) +
|
2020-11-05 19:56:26 +01:00
|
|
|
#scale_x_continuous(trans=log2_trans()) +
|
|
|
|
scale_y_continuous(trans=log2_trans())
|
|
|
|
|
|
|
|
# Render the plot
|
|
|
|
print(p)
|
|
|
|
|
|
|
|
# Save the png image
|
|
|
|
dev.off()
|
2021-03-05 16:21:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
png("heatmap.png", width=w*ppi, height=h*ppi, res=ppi)
|
|
|
|
#
|
|
|
|
## Create the plot with the normalized time vs nblocks
|
|
|
|
p = ggplot(df, aes(x=cbs, y=rbs, fill=logmtime)) +
|
|
|
|
geom_raster() +
|
|
|
|
scale_fill_gradient(high="black", low="white") +
|
|
|
|
coord_fixed() +
|
|
|
|
theme_bw() +
|
|
|
|
theme(plot.subtitle=element_text(size=8)) +
|
|
|
|
labs(x="cbs", y="rbs",
|
|
|
|
title=sprintf("Heat granularity"),
|
|
|
|
subtitle=input_file)
|
|
|
|
|
|
|
|
# Render the plot
|
|
|
|
print(p)
|
|
|
|
|
|
|
|
# Save the png image
|
|
|
|
dev.off()
|