Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
start on #170 and ms3_common.r script
Browse files Browse the repository at this point in the history
  • Loading branch information
taivop committed Dec 5, 2016
1 parent e389284 commit 810dc09
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.
37 changes: 37 additions & 0 deletions scripts/r/ms3_common.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
source("scripts/r/common.r")

memaslap_summary <- function(df) {
DROP_TIMES_BEFORE = 0 #2 * 60 # How many seconds in the beginning we want to drop
DROP_TIMES_AFTER = max((df %>% filter(type=="t"))$time) # - 2 * 60

df2 <- df %>%
mutate(min=min/1000, max=max/1000, avg=avg/1000, std=std/1000) %>%
filter(type=="t" & time > DROP_TIMES_BEFORE & time <= DROP_TIMES_AFTER)

means <- df2 %>%
group_by(request_type) %>%
summarise(mean_response_time=sum(ops*avg)/sum(ops))

res <- list()
tps_summed <- df2 %>% group_by(time, repetition) %>%
summarise(tps=sum(tps))
tps_values <- tps_summed$tps
res$tps_mean <- mean(tps_values)
res$mean_response_time_get <- (means %>% filter(request_type=="GET"))$mean_response_time[1]
res$mean_response_time_set <- (means %>% filter(request_type=="SET"))$mean_response_time[1]
res$mean_response_time <- (res$mean_response_time_get * sum((df2 %>% filter(request_type=="GET"))$ops) +
res$mean_response_time_set * sum((df2 %>% filter(request_type=="SET"))$ops)) / sum(df2$ops)
res$std_response_time <- sqrt(sum(df2$ops * df2$std * df2$std) / sum(df2$ops))

return(as.data.frame(res))
}

file_to_df <- function(file_path, sep=";") {
if(file.exists(file_path)) {
df <- read.csv(file_path, header=TRUE, sep=sep)
result <- df
} else {
result <- data.frame()
}
return(result)
}
6 changes: 6 additions & 0 deletions scripts/r/part1_mmm.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source("scripts/r/common.r")
source("scripts/r/ms3_common.r")

# ---- Directories ----
output_dir <- "results/analysis/part1_mmm"

42 changes: 1 addition & 41 deletions scripts/r/part5_irtl.r
Original file line number Diff line number Diff line change
@@ -1,50 +1,10 @@
source("scripts/r/common.r")

source("scripts/r/ms3_common.r")

# ---- Directories ----
output_dir <- "results/analysis/part5_irtl"
result_dir_base <- "results/replication"

# ---------------------------
# ---- HELPER FUNCTIONS -----
# ---------------------------

memaslap_summary <- function(df) {
DROP_TIMES_BEFORE = 0 #2 * 60 # How many seconds in the beginning we want to drop
DROP_TIMES_AFTER = max((df %>% filter(type=="t"))$time) # - 2 * 60

df2 <- df %>%
mutate(min=min/1000, max=max/1000, avg=avg/1000, std=std/1000) %>%
filter(type=="t" & time > DROP_TIMES_BEFORE & time <= DROP_TIMES_AFTER)

means <- df2 %>%
group_by(request_type) %>%
summarise(mean_response_time=sum(ops*avg)/sum(ops))

res <- list()
tps_summed <- df2 %>% group_by(time, repetition) %>%
summarise(tps=sum(tps))
tps_values <- tps_summed$tps
res$tps_mean <- mean(tps_values)
res$mean_response_time_get <- (means %>% filter(request_type=="GET"))$mean_response_time[1]
res$mean_response_time_set <- (means %>% filter(request_type=="SET"))$mean_response_time[1]
res$mean_response_time <- (res$mean_response_time_get * sum((df2 %>% filter(request_type=="GET"))$ops) +
res$mean_response_time_set * sum((df2 %>% filter(request_type=="SET"))$ops)) / sum(df2$ops)
res$std_response_time <- sqrt(sum(df2$ops * df2$std * df2$std) / sum(df2$ops))

return(as.data.frame(res))
}

file_to_df <- function(file_path, sep=";") {
if(file.exists(file_path)) {
df <- read.csv(file_path, header=TRUE, sep=sep)
result <- df
} else {
result <- data.frame()
}
return(result)
}

# ------------------
# ---- FILE IO -----
# ------------------
Expand Down

0 comments on commit 810dc09

Please sign in to comment.