Skip to content
Snippets Groups Projects
Commit 5d06c06d authored by Christian Wulf's avatar Christian Wulf
Browse files

moobench now logs heap memory and gc activity

parent 9e416c51
No related branches found
No related tags found
No related merge requests found
File deleted
This diff is collapsed.
library("data.table") # fread (fast csv reading)
pdf(file=sprintf("response-time-of-chunks-of-calls-%s.pdf", format(Sys.time(), format="%d-%B-%Y")))
filename = "response-time-of-chunks-of-calls.csv"
#filename = "response-time-of-chunks-of-calls.csv"
filename = "results-with-memory/raw-1-10-5.csv"
#filename = "results/raw-1-10-5.csv"
pdf(file=sprintf("%s-%s.pdf", filename, format(Sys.time(), format="%d-%B-%Y")))
numFirstValuesToIgnore = 10000000
chunkSize = 10000
colors = c("red", "blue", "green", "black")
colors = c("red", "blue", "green", "black", "darkred", "darkviolet")
# returns a data.table (by default)
## which enhances/extends a data.frame
......@@ -17,6 +18,9 @@ csvTable = fread(filename, skip=numFirstValuesToIgnore)
rowCount = csvTable[, .N]
cat(sprintf("\nYour input file contains %d lines.\n\n", rowCount))
chunkSize = rowCount/1000
cat(sprintf("The chunk size was set to %d calls.\n\n", chunkSize))
# csvTable with an additional column "id" which contains the row numbers (necessary for grouping; see below)
csvTable[, id:=1:.N]
......@@ -34,16 +38,39 @@ groupedMeanTime <- csvTable[, mean(V2), by=.((id-1)%/%chunkSize)]
groupedMedianTime <- csvTable[, median(V2), by=.((id-1)%/%chunkSize)]
groupedMinTime <- csvTable[, min(V2), by=.((id-1)%/%chunkSize)]
groupedMeanMemory = NULL
if (is.null(memory)) {
groupedMeanMemory <- list()
} else {
groupedMeanMemory <- csvTable[, mean(V3), by=.((id-1)%/%chunkSize)]
}
groupedSumGcActivity = NULL
if (is.null(gcActivity)) {
groupedSumGcActivity <- list()
} else {
groupedSumGcActivity <- csvTable[, sum(V4), by=.((id-1)%/%chunkSize)]
}
maxTimes <- groupedMaxTime[["V1"]]
meanTimes <- groupedMeanTime[["V1"]]
medianTimes <- groupedMedianTime[["V1"]]
minTimes <- groupedMinTime[["V1"]]
meanMemory <- groupedMeanMemory[["V1"]]
sumGcActivity <- groupedSumGcActivity[["V1"]]
##### start plotting #####
# increase the width of the plot (margin) due to multiple y-axes
#5.1,4.1,4.1,2.1 # default margin in R
par(mar = c(5.1+3,4.1,4.1+2,2.1+5))
# disable scientific number representation, e.g., 1e+07
options(scipen=10)
ts.plot(
ts(maxTimes), ts(meanTimes), ts(medianTimes), ts(minTimes),
ts(maxTimes), ts(meanTimes), ts(medianTimes), ts(minTimes),
gpars = list(yaxt="n", xaxt="n"),
col=colors,
type="l",
......@@ -58,17 +85,66 @@ axis(1, at = ticks, labels=sprintf("%dth", ticks))
ticks <- axTicks(2)
axis(2, at = ticks, labels=ticks/1000)
if (!is.null(memory)) {
par(new=T)
ts.plot(ts(meanMemory),
gpars = list(axes=FALSE, xaxt="n", yaxt="n"),
col=colors[5],
type="l",
xlab="",
ylab=""
)
# display y-ticks in mega bytes (so, we divide the current ticks by 1024*1024)
ticks <- axTicks(2)
axis(4, at = ticks, labels=sprintf("%.0f", ticks/(1024*1024)), col=colors[5])
mtext("Mean heap memory consumption (in MB) of a chunk", side=4, line=2)
}
if (!is.null(gcActivity)) {
par(new=T)
ts.plot(ts(sumGcActivity),
gpars = list(axes=FALSE, xaxt="n", yaxt="n"),
col=colors[6],
type="l",
xlab="",
ylab=""
)
# display y-ticks
ticks <- axTicks(2)
axis(4, at = ticks, labels=ticks, col=colors[6], line=4)
mtext("Sum GC collection count of a chunk", side=4, line=6)
}
# disable clipping (to not cut off the legends outside the plot)
par(xpd=TRUE)
legend("top", c("max", "mean", "median", "min"),
fill=colors,
horiz=TRUE,
title=sprintf("Each chunk of %d calls is aggregated via:", chunkSize)
title=sprintf("Each chunk of %d calls is aggregated via:", chunkSize),
inset=c(0,-0.16)
)
legend("bottom", c("mean heap", "sum gc"),
fill=colors[5:6],
horiz=TRUE,
title=sprintf("Memory observations"),
inset=c(0,-0.35)
)
# reset margin to default
par(mar = c(5.1,4.1,4.1,2.1))
i=1
plot(maxTimes, col=colors[i], type="l")
plot(meanTimes, col=colors[i+1], type="l")
plot(medianTimes, col=colors[i+2], type="l")
plot(minTimes, col=colors[i+3], type="l")
if (!is.null(memory)) {
plot(meanMemory, col=colors[i+4], type="l")
}
if (!is.null(gcActivity)) {
plot(sumGcActivity, col=colors[i+5], type="l")
}
### experimental code ###
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment