Last active
August 29, 2015 14:23
-
-
Save mavam/c40aca266dcbf94729f3 to your computer and use it in GitHub Desktop.
CAF memory consumption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
parse_measurement_filename <- function(path) { | |
filename <- strsplit(basename(path), "\\.")[[1]][1] | |
s <- strsplit(filename, "_")[[1]] | |
list(Cores=as.factor(s[1]), Run=as.factor(s[3]), Type=as.factor(s[5])) | |
} | |
parse_runtime_filename <- function(path) { | |
filename <- strsplit(basename(path), "\\.")[[1]][1] | |
s <- strsplit(filename, "_")[[1]] | |
list(Cores=as.factor(s[1]), Type=as.factor(s[3])) | |
} | |
ingest_measurement <- function(path) { | |
l <- parse_measurement_filename(path) | |
x <- read.table(path, col.names=c("Time", "Memory")) | |
x$Cores <- rep(l$Cores, nrow(x)) | |
x$Run <- rep(l$Run, nrow(x)) | |
x$Type <- rep(l$Type, nrow(x)) | |
x | |
} | |
ingest_runtime <- function(path) { | |
l <- parse_runtime_filename(path) | |
x <- read.table(path, col.names=c("Runtime")) | |
x$Cores <- rep(l$Cores, nrow(x)) | |
x$Type <- rep(l$Type, nrow(x)) | |
x | |
} | |
# Import all files. | |
path <- "data" | |
files <- list.files(path, ".*_run_.*\\.txt", full.names=TRUE) | |
measurements <- do.call(rbind, lapply(files, ingest_measurement)) | |
files <- list.files(path, ".*_runtime_.*\\.txt", full.names=TRUE) | |
runtimes <- do.call(rbind, lapply(files, ingest_runtime)) | |
# Global theme options | |
theme_set(theme_bw()) | |
theme_update(legend.key=element_rect(color="white")) | |
options(scipen=100000) | |
# Boxplot workaround: ensure their outlier have the same color as the contour. | |
update_geom_defaults("point", list(colour=NULL)) | |
# Plot a boxplot per core for all values across all runs. | |
p.box <- measurements %>% | |
ggplot(aes(x=Cores, y=Memory, color=Type)) + | |
geom_boxplot() #+ facet_wrap(~Type) | |
# Plot the maximum memory consumption across all runs. | |
p.box.max <- measurements %>% | |
group_by(Cores, Type, Run) %>% | |
summarize(Memory=max(Memory)) %>% | |
ggplot(aes(x=Cores, y=Memory, color=Type)) + | |
geom_boxplot() | |
# Plot the memory consumption over time for each run. | |
p.time.points <- measurements %>% | |
ggplot(aes(x=Time, y=Memory, color=Cores)) + | |
geom_point(size=1) + | |
facet_wrap(~Type) | |
# Same as above, but connect points from one run. | |
cores <- length(levels(measurements$Cores)) | |
p.time.lines <- measurements %>% | |
unite(c_r, Cores, Run, remove=FALSE) %>% | |
ggplot(aes(x=Time, y=Memory, group=c_r, color=Cores)) + | |
geom_line() + | |
geom_point(aes(fill=Cores), size=1, shape=21) + | |
scale_fill_manual(values=rep("white", cores)) + | |
facet_wrap(~Type) | |
# Same as above, but use one shape per run and lower alpha of lines. | |
runs <- length(levels(measurements$Run)) | |
p.time.shapes <- measurements %>% | |
unite(c_r, Cores, Run, remove=FALSE) %>% | |
ggplot(aes(x=Time, y=Memory, group=c_r, color=Cores)) + | |
geom_line(alpha=.5) + | |
geom_point(aes(shape=Run), size=1) + | |
scale_shape_manual(values=1:runs) + | |
facet_wrap(~Type) | |
p.runtime.box <- runtimes %>% | |
ggplot(aes(x=Cores, y=Runtime, color=Type)) + | |
geom_boxplot() | |
p.runtime.ecdf <- runtimes %>% | |
ggplot(aes(x=Runtime, color=Cores)) + | |
stat_ecdf() + | |
ylab("ECDF") + | |
facet_wrap(~Type, ncol=1) | |
p.runtime.ecdf2 <- runtimes %>% | |
ggplot(aes(x=Runtime, color=Type)) + | |
stat_ecdf() + | |
ylab("ECDF") + | |
facet_wrap(~Cores, ncol=1) | |
# Save boxplots plots | |
ggsave("measure-box.pdf", p.box) | |
ggsave("measure-box-max.pdf", p.box.max) | |
ggsave("runtime-box.pdf", p.runtime.box) | |
# Undo boxplot outlier workaround | |
update_geom_defaults("point", list(colour="black")) | |
# Save other plots | |
ggsave("measure-time-points.pdf", p.time.points) | |
ggsave("measure-time-lines.pdf", p.time.lines) | |
ggsave("measure-time-shapes.pdf", p.time.shapes) | |
ggsave("runtime-ecdf.pdf", p.runtime.ecdf) | |
ggsave("runtime-ecdf2.pdf", p.runtime.ecdf2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment