-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate_plots.R
79 lines (70 loc) · 2.54 KB
/
generate_plots.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
library(ggplot2)
library(plyr)
library(purrr)
calc_data <- function(data, variables, col = "unit") {
cdata <- ddply(data, .variables = variables,
.fun = function(d) {
N = length (d[[col]])
sd = sd(d[[col]])
c(N,
mean = mean(d[[col]]),
sd,
se = sd / sqrt(N)
)
}
)
cdata
}
color_palette <- function()
{
c("singly" = "#D55E00",
"doubly" = "#009E43",
"singly_cursor" = "#0072B2",
"doubly_cursor" = "#E69F00",
"draconic" = "#56B4E9")
}
bar_plot <- function(plot, title, x, y, palette = color_palette(), text_size=10)
{
plot +
geom_bar(position = position_dodge(width=0.9), width=0.8, stat="identity") +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), position=position_dodge(width=0.9), width=0.8) +
scale_fill_manual(values = palette) +
labs(x=x, y=y) +
theme(legend.position = "bottom",
legend.title = element_blank(),
text = element_text(size=text_size),
legend.text = element_text(size=text_size),
plot.title = element_text(size=text_size + 0.5),
axis.text.x = element_text(size=text_size),
axis.title.x = element_text(size=text_size),
axis.text.y = element_text(size=text_size),
axis.title.y = element_text(size=text_size)) +
guides(fill=guide_legend(nrow=1, byrow=TRUE))
}
read_file <- function(file)
{
read.csv(file=file, head=TRUE, sep=";")
}
benchmarks <- function() { c("draconic", "singly", "doubly", "singly_cursor", "doubly_cursor") }
plot_threads <- function(file, title)
{
data <- read_file(file)
data <- within(data, benchmark <- factor(benchmark,
levels=benchmarks()))
data$unit <- data[["Throughput..Kops.s."]]
cdata <- calc_data(data, c("threads", "benchmark"))
cdata$threads <- as.ordered(cdata$threads)
plot <- ggplot(data=cdata, aes(threads, mean, fill=benchmark))
bar_plot(plot, title=title, x="threads", y="Kops/sec")
}
calc_speedup <- function(file, base = "draconic") {
data <- read_file(file)
data$unit <- data[["Throughput..Kops.s."]]
cdata <- calc_data(data, c("threads", "benchmark"))
base <- cdata[cdata$benchmark == base,]
map(benchmarks(), .f = function(b) {
c(b, mean(cdata[cdata$benchmark == b,]$mean / base$mean))
})
}
plot <- plot_threads("results.csv", "Steady")
ggsave("threads.pdf", plot, width=300, height=95, units="mm", device=cairo_pdf)