Skip to content

Commit dac4502

Browse files
Ticket ## : Close case instance + test human task
1 parent 75b1884 commit dac4502

48 files changed

Lines changed: 1678 additions & 430 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
BenchmarkDotNetVersion <- "BenchmarkDotNet v0.12.0 "
2+
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE, showWarnings = FALSE)
3+
list.of.packages <- c("ggplot2", "dplyr", "gdata", "tidyr", "grid", "gridExtra", "Rcpp")
4+
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
5+
if(length(new.packages)) install.packages(new.packages, lib = Sys.getenv("R_LIBS_USER"), repos = "https://cran.rstudio.com/")
6+
library(ggplot2)
7+
library(dplyr)
8+
library(gdata)
9+
library(tidyr)
10+
library(grid)
11+
library(gridExtra)
12+
13+
isEmpty <- function(val){
14+
is.null(val) | val == ""
15+
}
16+
17+
createPrefix <- function(params){
18+
separator <- "-"
19+
values <- params[!isEmpty(params)]
20+
paste(replace(values, TRUE, paste0(separator, values)), collapse = "")
21+
}
22+
23+
ends_with <- function(vars, match, ignore.case = TRUE) {
24+
if (ignore.case)
25+
match <- tolower(match)
26+
n <- nchar(match)
27+
28+
if (ignore.case)
29+
vars <- tolower(vars)
30+
length <- nchar(vars)
31+
32+
substr(vars, pmax(1, length - n + 1), length) == match
33+
}
34+
std.error <- function(x) sqrt(var(x)/length(x))
35+
cummean <- function(x) cumsum(x)/(1:length(x))
36+
BenchmarkDotNetVersionGrob <- textGrob(BenchmarkDotNetVersion, gp = gpar(fontface=3, fontsize=10), hjust=1, x=1)
37+
nicePlot <- function(p) grid.arrange(p, bottom = BenchmarkDotNetVersionGrob)
38+
printNice <- function(p) print(nicePlot(p))
39+
ggsaveNice <- function(fileName, p, ...) {
40+
cat(paste0("*** Plot: ", fileName, " ***\n"))
41+
ggsave(fileName, plot = nicePlot(p), ...)
42+
cat("------------------------------\n")
43+
}
44+
45+
args <- commandArgs(trailingOnly = TRUE)
46+
files <- if (length(args) > 0) args else list.files()[list.files() %>% ends_with("-measurements.csv")]
47+
for (file in files) {
48+
title <- gsub("-measurements.csv", "", basename(file))
49+
measurements <- read.csv(file, sep = ";")
50+
51+
result <- measurements %>% filter(Measurement_IterationStage == "Result")
52+
if (nrow(result[is.na(result$Job_Id),]) > 0)
53+
result[is.na(result$Job_Id),]$Job_Id <- ""
54+
if (nrow(result[is.na(result$Params),]) > 0) {
55+
result[is.na(result$Params),]$Params <- ""
56+
} else {
57+
result$Job_Id <- trim(paste(result$Job_Id, result$Params))
58+
}
59+
result$Job_Id <- factor(result$Job_Id, levels = unique(result$Job_Id))
60+
61+
timeUnit <- "ns"
62+
if (min(result$Measurement_Value) > 1000) {
63+
result$Measurement_Value <- result$Measurement_Value / 1000
64+
timeUnit <- "us"
65+
}
66+
if (min(result$Measurement_Value) > 1000) {
67+
result$Measurement_Value <- result$Measurement_Value / 1000
68+
timeUnit <- "ms"
69+
}
70+
if (min(result$Measurement_Value) > 1000) {
71+
result$Measurement_Value <- result$Measurement_Value / 1000
72+
timeUnit <- "sec"
73+
}
74+
75+
resultStats <- result %>%
76+
group_by_(.dots = c("Target_Method", "Job_Id")) %>%
77+
summarise(se = std.error(Measurement_Value), Value = mean(Measurement_Value))
78+
79+
benchmarkBoxplot <- ggplot(result, aes(x=Target_Method, y=Measurement_Value, fill=Job_Id)) +
80+
guides(fill=guide_legend(title="Job")) +
81+
xlab("Target") +
82+
ylab(paste("Time,", timeUnit)) +
83+
ggtitle(title) +
84+
geom_boxplot()
85+
benchmarkBarplot <- ggplot(resultStats, aes(x=Target_Method, y=Value, fill=Job_Id)) +
86+
guides(fill=guide_legend(title="Job")) +
87+
xlab("Target") +
88+
ylab(paste("Time,", timeUnit)) +
89+
ggtitle(title) +
90+
geom_bar(position=position_dodge(), stat="identity")
91+
#geom_errorbar(aes(ymin=Value-1.96*se, ymax=Value+1.96*se), width=.2, position=position_dodge(.9))
92+
93+
printNice(benchmarkBoxplot)
94+
printNice(benchmarkBarplot)
95+
ggsaveNice(gsub("-measurements.csv", "-boxplot.png", file), benchmarkBoxplot)
96+
ggsaveNice(gsub("-measurements.csv", "-barplot.png", file), benchmarkBarplot)
97+
98+
for (target in unique(result$Target_Method)) {
99+
df <- result %>% filter(Target_Method == target)
100+
df$Launch <- factor(df$Measurement_LaunchIndex)
101+
df <- df %>% group_by(Job_Id, Launch) %>% mutate(cm = cummean(Measurement_Value))
102+
103+
densityPlot <- ggplot(df, aes(x=Measurement_Value, fill=Job_Id)) +
104+
ggtitle(paste(title, "/", target)) +
105+
xlab(paste("Time,", timeUnit)) +
106+
geom_density(alpha=.5, bw="SJ")
107+
printNice(densityPlot)
108+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-density.png"), file), densityPlot)
109+
110+
facetDensityPlot <- densityPlot + facet_wrap(~Job_Id)
111+
printNice(facetDensityPlot)
112+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-facetDensity.png"), file), facetDensityPlot)
113+
114+
for (params in unique(df$Params)) {
115+
paramsDf <- df %>% filter(Params == params)
116+
paramsDensityPlot <- ggplot(paramsDf, aes(x=Measurement_Value, fill=Job_Id)) +
117+
ggtitle(paste(title, "/", target, "/", params)) +
118+
xlab(paste("Time,", timeUnit)) +
119+
geom_density(alpha=.5, bw="SJ")
120+
printNice(paramsDensityPlot)
121+
prefix <- createPrefix(c(target,params))
122+
ggsaveNice(gsub("-measurements.csv", paste0(prefix, "-density.png"), file), paramsDensityPlot)
123+
124+
paramsFacetDensityPlot <- paramsDensityPlot + facet_wrap(~Job_Id)
125+
printNice(paramsFacetDensityPlot)
126+
ggsaveNice(gsub("-measurements.csv", paste0(prefix, "-facetDensity.png"), file), paramsFacetDensityPlot)
127+
}
128+
129+
for (job in unique(df$Job_Id)) {
130+
jobDf <- df %>% filter(Job_Id == job)
131+
timelinePlot <- ggplot(jobDf, aes(x = Measurement_IterationIndex, y=Measurement_Value, group=Launch, color=Launch)) +
132+
ggtitle(paste(title, "/", target, "/", job)) +
133+
xlab("IterationIndex") +
134+
ylab(paste("Time,", timeUnit)) +
135+
geom_line() +
136+
geom_point()
137+
printNice(timelinePlot)
138+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-", job, "-timeline.png"), file), timelinePlot)
139+
timelinePlotSmooth <- timelinePlot + geom_smooth()
140+
printNice(timelinePlotSmooth)
141+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-", job, "-timelineSmooth.png"), file), timelinePlotSmooth)
142+
143+
cummeanPlot <- ggplot(jobDf, aes(x = Measurement_IterationIndex, y=cm, group=Launch, color=Launch)) +
144+
ggtitle(paste(title, "/", target, "/", job)) +
145+
xlab("IterationIndex") +
146+
ylab(paste("Cumulative mean time,", timeUnit)) +
147+
geom_line() +
148+
geom_point()
149+
printNice(cummeanPlot)
150+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-", job, "-cummean.png"), file), cummeanPlot)
151+
152+
153+
densityPlotJob <- ggplot(jobDf, aes(x=Measurement_Value, fill="red")) +
154+
ggtitle(paste(title, "/", target, "/", job)) +
155+
xlab(paste("Time,", timeUnit)) +
156+
geom_density(alpha=.5, bw="SJ")
157+
printNice(densityPlotJob)
158+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-", job, "-density.png"), file), densityPlotJob)
159+
}
160+
161+
timelinePlot <- ggplot(df, aes(x = Measurement_IterationIndex, y=Measurement_Value, group=Launch, color=Launch)) +
162+
ggtitle(paste(title, "/", target)) +
163+
xlab("IterationIndex") +
164+
ylab(paste("Time,", timeUnit)) +
165+
geom_line() +
166+
geom_point() +
167+
facet_wrap(~Job_Id)
168+
printNice(timelinePlot)
169+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-facetTimeline.png"), file), timelinePlot)
170+
timelinePlotSmooth <- timelinePlot + geom_smooth()
171+
printNice(timelinePlotSmooth)
172+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-facetTimelineSmooth.png"), file), timelinePlotSmooth)
173+
174+
facetCummeanPlot <- ggplot(df, aes(x = Measurement_IterationIndex, y=cm, group=Launch, color=Launch)) +
175+
ggtitle(paste(title, "/", target)) +
176+
xlab("IterationIndex") +
177+
ylab(paste("Cumulative mean time,", timeUnit)) +
178+
geom_line() +
179+
geom_point() +
180+
facet_wrap(~Job_Id)
181+
printNice(facetCummeanPlot)
182+
ggsaveNice(gsub("-measurements.csv", paste0("-", target, "-cummean.png"), file), facetCummeanPlot)
183+
}
184+
}

0 commit comments

Comments
 (0)