timestampFile <- "timestamps.txt" memstatFile <- "memstat.txt" lines <- readLines(timestampFile) lines <- lines[grep("^[0-9]+", lines)] lines <- gsub(".---", "", lines) tm <- read.table(text=lines, col.names=c("timestamp", "text"), sep="|", quote="", stringsAsFactors=FALSE) tm <- tm[as.logical(nzchar(tm$text)),] lines <- readLines(memstatFile, warn=FALSE) cn <- as.character(read.table(text=lines[1L], nrows=1, comment="", stringsAsFactors=FALSE)[1, -1]) mm <- read.table(text=lines[c(-1L, -length(lines))], header=FALSE, col.names=cn, stringsAsFactors=FALSE) ## remove first occurence of duplicated timestamps #tm <- tm[!rev(duplicated(rev(tm$timestamp))),] ## remove everything that is before running synapter minTime <- min(tm$timestamp) maxTime <- max(tm$timestamp) mm <- mm[minTime <= mm$Time & mm$Time <= maxTime,] mm$Time <- mm$Time - minTime tm$timestamp <- tm$timestamp - minTime mm$Time <- mm$Time / 60 tm$timestamp <- tm$timestamp / 60 mm$VSZ <- mm$VSZ/1024 mm$RSS <- mm$RSS/1024 png("usage.png", width=1e4, height=1e3) plot(mm$Time, mm$VSZ, type="b", col="#377eb8", pch=15, ylim=c(0, max(mm$VSZ)), xaxt="n", main="Memory/CPU Usage synergise2", xlab="Time [min]", ylab="Memory Usage [MB]") axis(1, at=seq(0, max(tm$timestamp), by=5)) lines(mm$Time, mm$RSS, type="b", col="#4daf4a", pch=16) grid() abline(v=tm$timestamp, col="#e41a1c", lty=3) text(x=tm$timestamp, y=0, labels=tm$text, srt=90, col="#e41a1c", pos=4) abline(h=2e4, col="#ff7f00", lty=4) text(x=par("usr")[2], y=2e4, labels="20 GB", col="#ff7f00", pos=2) par(new=TRUE) plot(mm$Time, mm$X.usr, type="b", pch=17, col="#984ea3", xaxt="n", yaxt="n", xlab="", ylab="", ylim=c(0, max(mm$X.usr))) axis(4) mtext("CPU usage [%]", side=4, line=3) legend("bottomright", legend=c("Virtual Size", "Resident Set Size", "CPU Usage", "Events"), col=c("#377eb8", "#4daf4a", "#984ea3", "#e41a1c"), pch=c(15:17, NA), lwd=c(0, 0, 0, 1), bg="#ffffff") dev.off()