-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_graph.R
More file actions
46 lines (39 loc) · 1.06 KB
/
benchmark_graph.R
File metadata and controls
46 lines (39 loc) · 1.06 KB
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
library(stringr)
library(ggplot2)
library(rjson)
graph.data = function(json) {
name = json$slug
d = json$series[[1]]
df = data.frame(
size=unlist(lapply(d$results, function(x) x$size)),
mean=unlist(lapply(d$results, function(x) x$stats$mean)),
sd=unlist(lapply(d$results, function(x) x$stats$deviation))
)
names(df) = c("size", str_c(name, ".mean"), str_c(name, ".sd"))
df
}
ggplot.data = function(orig) {
t = melt(orig, id.vars="size")
t = cbind(t$size, colsplit(t$variable, "\\.", names=c("operation", "type")), t$value)
names(t) = c("size", "operation", "type", "value")
dcast(t, size + operation ~ ...)
}
graph = function(data) {
ggd = ggplot.data(data)
ggplot(ggd, aes(x=size, y=mean, colour=operation)) +
geom_point() +
geom_line() +
geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd)) +
ylab("seconds") +
theme_bw()
}
files = Sys.glob("tmp/*.json")
df = NULL
for(file in files) {
df2 = graph.data(fromJSON(file=file))
if(!is.null(df)) {
df = merge(df, df2, by="size", all=TRUE)
} else {
df = df2
}
}