Skip to content
Snippets Groups Projects
Commit 2de365cc authored by David Georg Reichelt's avatar David Georg Reichelt
Browse files

Add script for execution of R analysis without benchmark

parent 041bce91
Branches
No related tags found
No related merge requests found
#!/bin/bash
## Generate Results file
function run-r() {
R --vanilla --silent << EOF
results_fn="${RAWFN}"
outtxt_fn="${RESULTS_DIR}/results-text.txt"
outcsv_fn="${RESULTS_DIR}/results-text.csv"
configs.loop=${NUM_OF_LOOPS}
configs.recursion=${RECURSION_DEPTH}
configs.labels=c($LABELS)
results.count=${TOTAL_NUM_OF_CALLS}
results.skip=${TOTAL_NUM_OF_CALLS}/2
source("${RSCRIPT_PATH}")
EOF
}
function createVariantsString {
local LABELS=""
local variants=$(ls $RESULTS_DIR | grep ".csv" | awk -F'[.-]' '{print $4}' | sort | uniq | sed '/^[[:space:]]*$/d')
for variant in $variants
do
if [ -z "$LABELS" ]
then
LABELS="\"$variant\""
else
LABELS="$LABELS, \"$variant\""
fi
done
echo $LABELS
}
function createLatexTable {
cat $RESULTS_DIR/results-text.txt | tail -n 8 > transposeMe.csv
awk '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' transposeMe.csv > transposed.csv
cat transposed.csv | awk '{print "["$1-$3";"$1+$3"] & "$2}'
}
if [ "$#" -lt 1 ]
then
echo "Please pass folder with MooBench CSV files for analysis!"
exit 1
fi
RESULTS_DIR=$1
RAWFN=$RESULTS_DIR/raw
NUM_OF_LOOPS=10
RECURSION_DEPTH=10
TOTAL_NUM_OF_CALLS=2000000
LABELS=$(createVariantsString)
RSCRIPT_PATH=$MOOBENCH_HOME/frameworks/Kieker/scripts/stats.csv.r
run-r
createLatexTable
############################################
# R - script to collect all moobench results
############################################
# these values are here only as documentation. The parameters are set by benchmark.sh
#rm(list=ls(all=TRUE))
#data_fn="data/"
#folder_fn="results-benchmark-binary"
#results_fn=paste(data_fn,folder_fn,"/raw",sep="")
#outtxt_fn=paste(data_fn,folder_fn,"/results-text.txt",sep="")
#results_fn="raw"
#outtxt_fn="results-text.txt"
#########
# These are configuration parameters which are automatically prepended to this file by the benchmark.sh script.
# Therefore, they must not be set here. The following lines only serve as documentation.
#configs.loop=10
#configs.recursion=c(10)
#configs.labels=c("No Probe","Inactive Probe","Collecting Data","Writing Data (ASCII)", "Writing Data (Bin)")
#results.count=2000000
#results.skip=1000000
#bars.minval=500
#bars.maxval=600
##########
# Process configuration
# divisor 1 = nano, 1000 = micro, 1000000 = milli seconds
timeUnit <- 1000
# number of Kieker writer configurations
numberOfWriters <- length(configs.labels)
recursion_depth <- configs.recursion
numberOfValues <- configs.loop*(results.count-results.skip)
numbers <- c(1:(numberOfValues))
resultDimensionNames <- list(configs.labels, numbers)
# result values
resultsBIG <- array(dim=c(numberOfWriters, numberOfValues), dimnames=resultDimensionNames)
##########
# Create result
## "[ recursion , config , loop ]"
numOfRowsToRead <- results.count-results.skip
for (writer_idx in (1:numberOfWriters)) {
recordsPerSecond = c()
rpsLastDuration = 0
rpsCount = 0
file_idx <- writer_idx - 1
# loop
for (loop_counter in (1:configs.loop)) {
results_fn_filepath <- paste(results_fn, "-", loop_counter, "-", recursion_depth, "-", file_idx, ".csv", sep="")
message(results_fn_filepath)
results <- read.csv2(results_fn_filepath, nrows=numOfRowsToRead, skip=results.skip, quote="", colClasses=c("NULL","numeric", "numeric", "numeric"), comment.char="", col.names=c("thread_id", "duration_nsec", "gc", "t"), header=FALSE)
trx_idx <- c(1:numOfRowsToRead)
resultsBIG[writer_idx,trx_idx] <- results[["duration_nsec"]]
}
}
qnorm_value <- qnorm(0.975)
# print results
printDimensionNames <- list(c("mean","sd","ci95%","md25%","md50%","md75%","max","min"), c(1:numberOfWriters))
# row number == number of computed result values, e.g., mean, min, max
printvalues <- matrix(nrow=8, ncol=numberOfWriters, dimnames=printDimensionNames)
for (writer_idx in (1:numberOfWriters)) {
idx_mult <- c(1:numOfRowsToRead)
valuesBIG <- resultsBIG[writer_idx,idx_mult]/timeUnit
printvalues["mean",writer_idx] <- mean(valuesBIG)
printvalues["sd",writer_idx] <- sd(valuesBIG)
printvalues["ci95%",writer_idx] <- qnorm_value*sd(valuesBIG)/sqrt(length(valuesBIG))
printvalues[c("md25%","md50%","md75%"),writer_idx] <- quantile(valuesBIG, probs=c(0.25, 0.5, 0.75))
printvalues["max",writer_idx] <- max(valuesBIG)
printvalues["min",writer_idx] <- min(valuesBIG)
}
resultstext <- formatC(printvalues,format="f",digits=4,width=8)
print(resultstext)
write(paste("Recursion Depth: ", recursion_depth),file=outtxt_fn,append=TRUE)
write("response time",file=outtxt_fn,append=TRUE)
write.table(resultstext,file=outtxt_fn,append=TRUE,quote=FALSE,sep="\t",col.names=FALSE)
concResult <- ""
headResult <- ""
# write the first n-1 elements preceded by a comma (,)
for (writer_idx in (1:(numberOfWriters-1))) {
headResult <- paste(headResult, configs.labels[writer_idx], ",")
concResult <- paste(concResult, printvalues["mean",writer_idx], ",")
}
# write the last without a comma
headResult <- paste(headResult, configs.labels[numberOfWriters])
concResult <- paste(concResult, printvalues["mean", numberOfWriters])
write(headResult,file=outcsv_fn,append=TRUE)
write(concResult,file=outcsv_fn,append=TRUE)
# end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment