Skip to content
Snippets Groups Projects

Introduce USL extensions

1 unresolved thread
18 files
+ 79
62
Compare changes
  • Side-by-side
  • Inline
Files
18
@@ -3,9 +3,14 @@ title: "USL Offline Analysis Tool"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook for performing USL analysis on the benchmark results of Theodolite. The notebook is configured to write the USL analysis results to the file system.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.
At the top of the document there are the following parameters that can be set:
- resources and load dimension names: According to the version of Theodolite, the format of the CSV files may be different. Therefore, it is possible to set the resources and load dimension names to the values of the input CSV files
- directory: Specifies the directory where the benchmark results files are located
- expID: Specifies the ID of the benchmark in Theodolite
- resources and load normalization: There are cases where the computation of the USL model lacks numerical stability because of floating point precision. Consequently, it can make sense to normalize the load values in order to be able to generate a USL model. This only influences the gamma parameter of the USL proportionally by the normalization factor. In other cases, one may be interested to also normalize the resources dimension values.
```{r}
library(usl)
@@ -13,18 +18,20 @@ library(jsonlite)
library(dplyr)
library(purrr)
directory <- "./"
expID <- "19"
resources_normalization <- 1
load_normalization <- 1000
resources_dimension_name <- "resource" # may be set to the according CSV file column
load_dimension_name <- "loads" # may be set to the according CSV file column
directory <- "./" # directory which contains the exp{N}_capacity.csv and exp{N}-results files
expID <- "28" # the experiment ID {N}
resources_normalization <- 1 # all the resources values are divided by this value
load_normalization <- 1000 # all the load values are divided by this value
filename <- paste("./exp", expID, "_capacity.csv", sep = "")
# import data and compute usl model
# capacity units are changed to a thousand * (load value)
dataset <- read.csv(filename, colClasses = c("numeric", "numeric"))
dataset["resources"] = map(dataset["resources"], function(x) x/resources_normalization)
dataset["load"] = map(dataset["load"], function(x) ((x/load_normalization)))
usl.model <- usl(load ~ resources, dataset)
dataset[resources_dimension_name] = map(dataset[resources_dimension_name], function(x) x/resources_normalization)
dataset[load_dimension_name] = map(dataset[load_dimension_name], function(x) ((x/load_normalization)))
usl.model <- usl(as.formula(paste(load_dimension_name, resources_dimension_name, sep = " ~ ")), dataset)
# print summary of model + visualizations
sink("summary.txt")
@@ -54,17 +61,17 @@ pdf("efficiency-plot.pdf")
efficiencyValues <- efficiency(usl.model)
par(ps=21)
names(efficiencyValues)
plot(efficiencyValues, x = names(efficiencyValues), type = "b", pch = 19, xlab = "resources", ylab = "efficiency rate", xaxt = "n", ylim = c(0, 2))
axis(side=1, at=dataset$resources)
plot(efficiencyValues, x = names(efficiencyValues), type = "b", pch = 19, xlab = resources_dimension_name, ylab = "efficiency rate", xaxt = "n", ylim = c(0, 2))
axis(side=1, at=dataset[[resources_dimension_name]])
dev.off()
# plot usl function
plot.new()
pdf("usl-plotted.pdf") # pdf export start
par(ps=19)
plot(dataset, pch = 16, ylim = c(0, 5), xlim = c(0, max(dataset["resources"])), xaxt="n", xlab="proportional resource dimension", ylab="capacity (thousand traces per second)")
axis(side=1, at=dataset$resources)
plot(function(x) x*coef(usl.model)[["gamma"]], 0, max(dataset["resources"]), add = TRUE)
plot(dataset, pch = 16, ylim = c(0, max(dataset[load_dimension_name])), xlim = c(0, max(dataset[resources_dimension_name])), xaxt="n", xlab=resources_dimension_name, ylab=load_dimension_name)
axis(side=1, at=dataset[[resources_dimension_name]])
plot(function(x) x*coef(usl.model)[["gamma"]], 0, max(dataset[resources_dimension_name]), add = TRUE)
plot(usl.model, col="red", add=TRUE, bounds = FALSE)
dev.off() # pdf export end
@@ -73,10 +80,10 @@ plot.new()
results <- unlist(read_json(path = paste("exp", expID, "-result", sep = ""))["results"][[1]])
results_df <- data.frame(matrix(results, ncol = 3, byrow = TRUE))
colnames(results_df) <- c("load", "resources", "success")
slo_experiments <- results_df %>% group_by(resources) %>% summarise(n_distinct(load))
slo_experiments <- results_df %>% group_by("resources") %>% summarise(n_distinct("load"))
pdf("number-experiments-bars.pdf")
par(ps=21)
barplot(slo_experiments$`n_distinct(load)`, names.arg = slo_experiments$resources, xlab = "resources", ylab = "executed SLO experiments")
barplot(slo_experiments$`n_distinct(load)`, names.arg = slo_experiments$resources, xlab = resources_dimension_name, ylab = "executed SLO experiments")
dev.off()
```
Loading