From 1835032c19bf7ef216cd05f8174da529f741348d Mon Sep 17 00:00:00 2001
From: Reiner Jung <reiner.jung@email.uni-kiel.de>
Date: Fri, 22 Jul 2022 19:11:43 +0200
Subject: [PATCH] Updated structure. Harmonized structures.

---
 frameworks/Kieker/benchmark.sh                | 174 ++++++----------
 frameworks/Kieker/{config => config.rc}       |   4 +-
 frameworks/Kieker/functions.sh                | 108 ++++++++++
 frameworks/Kieker/labels.sh                   |   0
 frameworks/common-functions.sh                |  39 +---
 frameworks/inspectIT/benchmark.sh             | 196 +++++++-----------
 frameworks/inspectIT/config.rc                |  10 +
 frameworks/inspectIT/functions.sh             | 114 ++++++++++
 .../run-benchmark.sh => run-benchmark.sh      |   0
 9 files changed, 375 insertions(+), 270 deletions(-)
 rename frameworks/Kieker/{config => config.rc} (88%)
 create mode 100644 frameworks/Kieker/functions.sh
 mode change 100755 => 100644 frameworks/Kieker/labels.sh
 create mode 100644 frameworks/inspectIT/config.rc
 create mode 100644 frameworks/inspectIT/functions.sh
 rename frameworks/Kieker/run-benchmark.sh => run-benchmark.sh (100%)

diff --git a/frameworks/Kieker/benchmark.sh b/frameworks/Kieker/benchmark.sh
index 64ee1a7..0f5f415 100755
--- a/frameworks/Kieker/benchmark.sh
+++ b/frameworks/Kieker/benchmark.sh
@@ -1,8 +1,17 @@
 #!/bin/bash
 
+#
+# Kieker benchmark script
+#
+# Usage: benchmark.sh [execute|test]
+
 # configure base dir
 BASE_DIR=$(cd "$(dirname "$0")"; pwd)
 
+#
+# source functionality
+#
+
 if [ ! -d "${BASE_DIR}" ] ; then
 	echo "Base directory ${BASE_DIR} does not exist."
 	exit 1
@@ -10,34 +19,35 @@ fi
 
 # load configuration and common functions
 if [ -f "${BASE_DIR}/config" ] ; then
-	. "${BASE_DIR}/config"
+	source "${BASE_DIR}/config.rc"
 else
-	echo "Missing configuration: ${BASE_DIR}/config"
+	echo "Missing configuration: ${BASE_DIR}/config.rc"
 	exit 1
 fi
 
 if [ -f "${BASE_DIR}/../common-functions.sh" ] ; then
-	. "${BASE_DIR}/../common-functions.sh"
+	source "${BASE_DIR}/../common-functions.sh"
 else
-	echo "Missing configuration: ${BASE_DIR}/../common-functions.sh"
+	echo "Missing library: ${BASE_DIR}/../common-functions.sh"
 	exit 1
 fi
 
-getKiekerAgent
-
-RECEIVER_ARCHIVE="${BASE_DIR}/../../tools/receiver/build/distributions/receiver.tar"
-
-if [ -f "${RECEIVER_ARCHIVE}" ] ; then
-	tar -xpf "${RECEIVER_ARCHIVE}"
+if [ -f "${BASE_DIR}/functions.sh" ] ; then
+	source "${BASE_DIR}/functions.sh"
 else
-	echo "Error receiver not found at ${RECEIVER_ARCHIVE}"
+	echo "Missing: ${BASE_DIR}/functions.sh"
+	exit 1
+fi
+if [ -f "${BASE_DIR}/labels.sh" ] ; then
+	source "${BASE_DIR}/labels.sh"
+else
+	echo "Missing file: ${BASE_DIR}/labels.sh"
 	exit 1
 fi
 
-PARENT=`dirname "${RESULTS_DIR}"`
-RECEIVER_BIN="${BASE_DIR}/receiver/bin/receiver"
-
+#
 # check command line parameters
+#
 if [ "$1" == "" ] ; then
 	MODE="execute"
 else
@@ -49,7 +59,30 @@ else
 	OPTION="$2"
 fi
 
-# test input parameters and configuration
+#
+# Setup
+#
+
+info "----------------------------------"
+info "Setup..."
+info "----------------------------------"
+
+# load agent
+getAgent
+
+# Find receiver and extract it
+RECEIVER_ARCHIVE="${BASE_DIR}/../../tools/receiver/build/distributions/receiver.tar"
+
+if [ -f "${RECEIVER_ARCHIVE}" ] ; then
+	tar -xpf "${RECEIVER_ARCHIVE}"
+else
+	echo "Error receiver not found at ${RECEIVER_ARCHIVE}"
+	exit 1
+fi
+
+PARENT=`dirname "${RESULTS_DIR}"`
+RECEIVER_BIN="${BASE_DIR}/receiver/bin/receiver"
+
 checkDirectory DATA_DIR "${DATA_DIR}" create
 checkDirectory result-base "${PARENT}"
 checkFile ApsectJ-Agent "${AGENT}"
@@ -58,10 +91,8 @@ checkFile Labels "${BASE_DIR}/labels.sh"
 checkFile R-script "${RSCRIPT_PATH}"
 checkDirectory results-directory "${RESULTS_DIR}" recreate
 checkFile log "${DATA_DIR}/kieker.log" clean
-
-info "----------------------------------"
-info "Running benchmark..."
-info "----------------------------------"
+checkFile MooBench "${BASE_DIR}/MooBench.jar"
+checkExecutable java "${JAVA_BIN}"
 
 TIME=`expr ${METHOD_TIME} \* ${TOTAL_NUM_OF_CALLS} / 1000000000 \* 4 \* ${RECURSION_DEPTH} \* ${NUM_OF_LOOPS} + ${SLEEP_TIME} \* 4 \* ${NUM_OF_LOOPS}  \* ${RECURSION_DEPTH} + 50 \* ${TOTAL_NUM_OF_CALLS} / 1000000000 \* 4 \* ${RECURSION_DEPTH} \* ${NUM_OF_LOOPS} `
 info "Experiment will take circa ${TIME} seconds."
@@ -81,9 +112,6 @@ declare -a RECEIVER
 # Title
 declare -a TITLE
 
-# Configurations
-source "${BASE_DIR}/labels.sh"
-
 WRITER_CONFIG[0]=""
 WRITER_CONFIG[1]="-Dkieker.monitoring.enabled=false -Dkieker.monitoring.writer=kieker.monitoring.writer.dump.DumpWriter"
 WRITER_CONFIG[2]="-Dkieker.monitoring.enabled=true -Dkieker.monitoring.writer=kieker.monitoring.writer.dump.DumpWriter"
@@ -107,105 +135,33 @@ METHOD_TIME=${METHOD_TIME}
 RECURSION_DEPTH=${RECURSION_DEPTH}
 EOF
 
+info "Ok"
+
 sync
 
-#################################
-# function: execute an experiment
+
 #
-# $1 = i iterator
-# $2 = j iterator
-# $3 = k iterator
-# $4 = title
-# $5 = writer parameters
-function execute-experiment() {
-    loop="$1"
-    recursion="$2"
-    index="$3"
-    title="$4"
-    kieker_parameters="$5"
-
-    info " # recursion=${recursion} loop=${loop} writer=${index} ${title}"
-    echo " # ${loop}.${recursion}.${index} ${title}" >> "${DATA_DIR}/kieker.log"
-
-    if [  "${kieker_parameters}" = "" ] ; then
-       BENCHMARK_OPTS="${JAVA_ARGS}"
-    else
-       BENCHMARK_OPTS="${JAVA_ARGS} ${LTW_ARGS} ${KIEKER_ARGS} ${kieker_parameters}"
-    fi
-
-    echo "Run options: ${BENCHMARK_OPTS} -jar MooBench.jar"
-
-    ${JAVA_BIN} ${BENCHMARK_OPTS} -jar MooBench.jar \
-	--application moobench.application.MonitoredClassSimple \
-        --output-filename "${RAWFN}-${loop}-${recursion}-${index}.csv" \
-        --total-calls "${TOTAL_NUM_OF_CALLS}" \
-        --method-time "${METHOD_TIME}" \
-        --total-threads 1 \
-        --recursion-depth "${recursion}" &> "${RESULTS_DIR}/output_${loop}_${RECURSION_DEPTH}_${index}.txt"
-
-    rm -rf "${DATA_DIR}"/kieker-*
-
-    [ -f "${DATA_DIR}/hotspot.log" ] && mv "${DATA_DIR}/hotspot.log" "${RESULTS_DIR}/hotspot-${loop}-${recursion}-${index}.log"
-    echo >> "${DATA_DIR}/kieker.log"
-    echo >> "${DATA_DIR}/kieker.log"
-    sync
-    sleep "${SLEEP_TIME}"
-}
-
-function execute-benchmark-body() {
-  index="$1"
-  loop="$2"
-  recursion="$3"
-  if [[ "${RECEIVER[$index]}" ]] ; then
-     echo "receiver ${RECEIVER[$index]}"
-     ${RECEIVER[$index]} >> "${DATA_DIR}/kieker.receiver-${i}-${index}.log" &
-     RECEIVER_PID=$!
-     echo "PID $RECEIVER_PID"
-  fi
-
-  execute-experiment "$loop" "$recursion" "$index" "${TITLE[$index]}" "${WRITER_CONFIG[$index]}"
-
-  if [[ "${RECEIVER_PID}" ]] ; then
-     kill -TERM "${RECEIVER_PID}"
-     unset RECEIVER_PID
-  fi
-}
-
-## Execute Benchmark
-function execute-benchmark() {
-  for ((loop=1;loop<="${NUM_OF_LOOPS}";loop+=1)); do
-    recursion="${RECURSION_DEPTH}"
-
-    info "## Starting iteration ${loop}/${NUM_OF_LOOPS}"
-    echo "## Starting iteration ${loop}/${NUM_OF_LOOPS}" >> "${DATA_DIR}/kieker.log"
-
-    for ((index=0;index<${#WRITER_CONFIG[@]};index+=1)); do
-      execute-benchmark-body $index $loop $recursion
-    done
-
-    printIntermediaryResults
-  done
-
-  mv "${DATA_DIR}/kieker.log" "${RESULTS_DIR}/kieker.log"
-  [ -f "${RESULTS_DIR}/hotspot-1-${RECURSION_DEPTH}-1.log" ] && grep "<task " "${RESULTS_DIR}"/hotspot-*.log > "${RESULTS_DIR}/log.log"
-  [ -f "${DATA_DIR}/errorlog.txt" ] && mv "${DATA_DIR}/errorlog.txt" "${RESULTS_DIR}"
-}
-
-## Execute benchmark
+# Run benchmark
+#
+
+info "----------------------------------"
+info "Running benchmark..."
+info "----------------------------------"
+
 if [ "$MODE" == "execute" ] ; then
    if [ "$OPTION" == "" ] ; then
-     execute-benchmark
+     executeBenchmark
    else
-     execute-benchmark-body $OPTION 1 1
+     executeBenchmarkBody $OPTION 1 1
    fi
 
    # Create R labels
    LABELS=$(createRLabels)
-   run-r
+   runR
 
-   cleanup-results
+   cleanupResults
 else
-   execute-benchmark-body $OPTION 1 1
+   executeBenchmarkBody $OPTION 1 1
 fi
 
 info "Done."
diff --git a/frameworks/Kieker/config b/frameworks/Kieker/config.rc
similarity index 88%
rename from frameworks/Kieker/config
rename to frameworks/Kieker/config.rc
index 81d8160..1febf6c 100644
--- a/frameworks/Kieker/config
+++ b/frameworks/Kieker/config.rc
@@ -2,15 +2,13 @@
 # MooBench configuration parameter
 
 # path setup
-JAVA_BIN="java"
+JAVA_BIN="/usr/bin/java"
 
 RSCRIPT_PATH="${BASE_DIR}/stats.csv.r"
 
 DATA_DIR="${BASE_DIR}/data"
 AGENT="${BASE_DIR}/kieker-2.0.0-SNAPSHOT-aspectj.jar"
 
-BATCH_MODE="yes"
-
 # in-jar locations
 AOP="file:"$(pwd)"/src/META-INF/kieker.aop.xml"
 
diff --git a/frameworks/Kieker/functions.sh b/frameworks/Kieker/functions.sh
new file mode 100644
index 0000000..8d5b281
--- /dev/null
+++ b/frameworks/Kieker/functions.sh
@@ -0,0 +1,108 @@
+# Kieker specific functions
+
+# ensure the script is sourced
+if [ "${BASH_SOURCE[0]}" -ef "$0" ]
+then
+    echo "Hey, you should source this script, not execute it!"
+    exit 1
+fi
+
+function getAgent() {
+	info "Checking whether Kieker is present in $AGENT"
+	if [ ! -f $AGENT ] ; then
+		# get agent
+		export VERSION_PATH=`curl "https://oss.sonatype.org/service/local/repositories/snapshots/content/net/kieker-monitoring/kieker/" | grep '<resourceURI>' | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | grep '/$' | grep -v ".xml" | head -n 1`
+		export AGENT_PATH=`curl "${VERSION_PATH}" | grep 'aspectj.jar</resourceURI' | sort | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | tail -1`
+		curl "${AGENT_PATH}" > "${AGENT}"
+		
+		if [ ! -f $AGENT ] | [ -s $AGENT ] ; then
+			error "Kieker download from $AGENT_PATH failed; please asure that a correct Kieker AspectJ file is present!"
+		fi
+		
+	fi
+}
+
+#################################
+# function: execute an experiment
+#
+# $1 = i iterator
+# $2 = j iterator
+# $3 = k iterator
+# $4 = title
+# $5 = writer parameters
+function executeExperiment() {
+    loop="$1"
+    recursion="$2"
+    index="$3"
+    title="$4"
+    kieker_parameters="$5"
+
+    info " # recursion=${recursion} loop=${loop} writer=${index} ${title}"
+    echo " # ${loop}.${recursion}.${index} ${title}" >> "${DATA_DIR}/kieker.log"
+
+    if [  "${kieker_parameters}" = "" ] ; then
+       BENCHMARK_OPTS="${JAVA_ARGS}"
+    else
+       BENCHMARK_OPTS="${JAVA_ARGS} ${LTW_ARGS} ${KIEKER_ARGS} ${kieker_parameters}"
+    fi
+
+    echo "Run options: ${BENCHMARK_OPTS} -jar MooBench.jar"
+
+    ${JAVA_BIN} ${BENCHMARK_OPTS} -jar "${BASE_DIR}/MooBench.jar" \
+	--application moobench.application.MonitoredClassSimple \
+        --output-filename "${RAWFN}-${loop}-${recursion}-${index}.csv" \
+        --total-calls "${TOTAL_NUM_OF_CALLS}" \
+        --method-time "${METHOD_TIME}" \
+        --total-threads 1 \
+        --recursion-depth "${recursion}" &> "${RESULTS_DIR}/output_${loop}_${RECURSION_DEPTH}_${index}.txt"
+
+    rm -rf "${DATA_DIR}"/kieker-*
+
+    [ -f "${DATA_DIR}/hotspot.log" ] && mv "${DATA_DIR}/hotspot.log" "${RESULTS_DIR}/hotspot-${loop}-${recursion}-${index}.log"
+    echo >> "${DATA_DIR}/kieker.log"
+    echo >> "${DATA_DIR}/kieker.log"
+    sync
+    sleep "${SLEEP_TIME}"
+}
+
+function executeBenchmarkBody() {
+  index="$1"
+  loop="$2"
+  recursion="$3"
+  if [[ "${RECEIVER[$index]}" ]] ; then
+     echo "receiver ${RECEIVER[$index]}"
+     ${RECEIVER[$index]} >> "${DATA_DIR}/kieker.receiver-${i}-${index}.log" &
+     RECEIVER_PID=$!
+     echo "PID $RECEIVER_PID"
+  fi
+
+  executeExperiment "$loop" "$recursion" "$index" "${TITLE[$index]}" "${WRITER_CONFIG[$index]}"
+
+  if [[ "${RECEIVER_PID}" ]] ; then
+     kill -TERM "${RECEIVER_PID}"
+     unset RECEIVER_PID
+  fi
+}
+
+## Execute Benchmark
+function executeBenchmark() {
+  for ((loop=1;loop<="${NUM_OF_LOOPS}";loop+=1)); do
+    recursion="${RECURSION_DEPTH}"
+
+    info "## Starting iteration ${loop}/${NUM_OF_LOOPS}"
+    echo "## Starting iteration ${loop}/${NUM_OF_LOOPS}" >> "${DATA_DIR}/kieker.log"
+
+    for ((index=0;index<${#WRITER_CONFIG[@]};index+=1)); do
+      executeBenchmarkBody $index $loop $recursion
+    done
+
+    printIntermediaryResults
+  done
+
+  mv "${DATA_DIR}/kieker.log" "${RESULTS_DIR}/kieker.log"
+  [ -f "${RESULTS_DIR}/hotspot-1-${RECURSION_DEPTH}-1.log" ] && grep "<task " "${RESULTS_DIR}"/hotspot-*.log > "${RESULTS_DIR}/log.log"
+  [ -f "${DATA_DIR}/errorlog.txt" ] && mv "${DATA_DIR}/errorlog.txt" "${RESULTS_DIR}"
+}
+
+
+# end
diff --git a/frameworks/Kieker/labels.sh b/frameworks/Kieker/labels.sh
old mode 100755
new mode 100644
diff --git a/frameworks/common-functions.sh b/frameworks/common-functions.sh
index dbff157..b5cacc8 100755
--- a/frameworks/common-functions.sh
+++ b/frameworks/common-functions.sh
@@ -20,48 +20,13 @@ function getSum {
 }
 
 ## Clean up raw results
-function cleanup-results() {
+function cleanupResults() {
   zip -jqr ${RESULTS_DIR}/results.zip ${RAWFN}*
   rm -f ${RAWFN}*
   [ -f ${DATA_DIR}/nohup.out ] && cp ${DATA_DIR}/nohup.out ${RESULTS_DIR}
   [ -f ${DATA_DIR}/nohup.out ] && > ${DATA_DIR}/nohup.out
 }
 
-function checkMoobenchApplication() {
-	if [ ! -f "MooBench.jar" ]
-	then
-		echo "MooBench.jar missing; please build it first using ./gradlew assemble in the main folder"
-		exit 1
-	fi
-}
-
-function getKiekerAgent() {
-	echo "Checking whether Kieker is present in $AGENT"
-	if [ ! -f $AGENT ]
-	then
-		# get agent
-		export VERSION_PATH=`curl "https://oss.sonatype.org/service/local/repositories/snapshots/content/net/kieker-monitoring/kieker/" | grep '<resourceURI>' | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | grep '/$' | grep -v ".xml" | head -n 1`
-		export AGENT_PATH=`curl "${VERSION_PATH}" | grep 'aspectj.jar</resourceURI' | sort | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | tail -1`
-		curl "${AGENT_PATH}" > "${AGENT}"
-		
-		if [ ! -f $AGENT ] | [ -s $AGENT ]
-		then
-			echo "Kieker download from $AGENT_PATH failed; please asure that a correct Kieker AspectJ file is present!"
-		fi
-		
-	fi
-}
-
-function getInspectItAgent() {
-	if [ ! -d agent ]
-	then
-		mkdir agent
-		cd agent
-		wget https://github.com/inspectIT/inspectit-ocelot/releases/download/1.11.1/inspectit-ocelot-agent-1.11.1.jar
-		cd ..
-	fi
-}
-
 function getOpentelemetryAgent() {
 	if [ ! -f "${BASE_DIR}/lib/opentelemetry-javaagent.jar" ]
 	then
@@ -86,7 +51,7 @@ function createRLabels() {
 }
 
 ## Generate Results file
-function run-r() {
+function runR() {
 R --vanilla --silent << EOF
 results_fn="${RAWFN}"
 outtxt_fn="${RESULTS_DIR}/results-text.txt"
diff --git a/frameworks/inspectIT/benchmark.sh b/frameworks/inspectIT/benchmark.sh
index ef9dc50..d478c4d 100755
--- a/frameworks/inspectIT/benchmark.sh
+++ b/frameworks/inspectIT/benchmark.sh
@@ -1,130 +1,78 @@
 #!/bin/bash
 
-function runNoInstrumentation {
-    # No instrumentation
-    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
-    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
-    ${JAVA_BIN} ${JAVA_ARGS_NOINSTR} ${JAR} \
-        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
-        --total-calls ${TOTAL_NUM_OF_CALLS} \
-        --method-time ${METHOD_TIME} \
-        --total-threads ${THREADS} \
-        --recursion-depth ${RECURSION_DEPTH} \
-        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
-}
-
-function runInspectITDeactivated {
-    k=`expr ${k} + 1`
-    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
-    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
-    sleep $SLEEP_TIME
-    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_DEACTIVATED} ${JAR} \
-        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
-        --total-calls ${TOTAL_NUM_OF_CALLS} \
-        --method-time ${METHOD_TIME} \
-        --total-threads ${THREADS} \
-        --recursion-depth ${RECURSION_DEPTH} \
-        --force-terminate \
-        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
-    sleep $SLEEP_TIME
-}
-
-function runInspectITNullWriter {
-    k=`expr ${k} + 1`
-    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
-    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
-    sleep $SLEEP_TIME
-    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_NULLWRITER} ${JAR} \
-        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
-        --total-calls ${TOTAL_NUM_OF_CALLS} \
-        --method-time ${METHOD_TIME} \
-        --total-threads ${THREADS} \
-        --recursion-depth ${RECURSION_DEPTH} \
-        --force-terminate \
-        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
-    sleep $SLEEP_TIME
-}
-
-
-function runInspectITZipkin {
-    # InspectIT (minimal)
-    k=`expr ${k} + 1`
-    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
-    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
-    startZipkin
-    sleep $SLEEP_TIME
-    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_ZIPKIN} ${JAR} \
-        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
-        --total-calls ${TOTAL_NUM_OF_CALLS} \
-        --method-time ${METHOD_TIME} \
-        --total-threads ${THREADS} \
-        --recursion-depth ${RECURSION_DEPTH} \
-        --force-terminate \
-        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
-    stopBackgroundProcess
-    sleep $SLEEP_TIME
-}
-
-function runInspectITPrometheus {
-    # InspectIT (minimal)
-    k=`expr ${k} + 1`
-    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
-    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
-    startPrometheus
-    sleep $SLEEP_TIME
-    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_PROMETHEUS} ${JAR} \
-        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
-        --total-calls ${TOTAL_NUM_OF_CALLS} \
-        --method-time ${METHOD_TIME} \
-        --total-threads ${THREADS} \
-        --recursion-depth ${RECURSION_DEPTH} \
-        --force-terminate \
-        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
-    stopBackgroundProcess
-    sleep $SLEEP_TIME
-}
-
-function cleanup {
-	[ -f "${BASE_DIR}/hotspot.log" ] && mv "${BASE_DIR}/hotspot.log" "${RESULTS_DIR}/hotspot-${i}-${j}-${k}.log"
-	echo >> "${BASE_DIR}/inspectIT.log"
-	echo >> "${BASE_DIR}/inspectIT.log"
-	sync
-	sleep "${SLEEP_TIME}"
-}
-
-function getSum {
-  awk '{sum += $1; square += $1^2} END {print "Average: "sum/NR" Standard Deviation: "sqrt(square / NR - (sum/NR)^2)" Count: "NR}'
-}
-
-JAVA_BIN=""
-
-BASE_DIR=$(pwd)
-RSCRIPT_PATH="../stats.csv.r"
-
-source ../common-functions.sh
-source labels.sh
-
-checkMoobenchApplication
-
-getInspectItAgent
-
-#MORE_PARAMS="--quickstart"
-MORE_PARAMS="${MORE_PARAMS}"
+#
+# inspectIT benchmark script
+#
+# Usage: benchmark.sh
+
+# configure base dir
+BASE_DIR=$(cd "$(dirname "$0")"; pwd)
+
+#
+# source functionality
+#
+
+if [ ! -d "${BASE_DIR}" ] ; then
+	echo "Base directory ${BASE_DIR} does not exist."
+	exit 1
+fi
+
+# load configuration and common functions
+if [ -f "${BASE_DIR}/config" ] ; then
+	source "${BASE_DIR}/config.rc"
+else
+	echo "Missing configuration: ${BASE_DIR}/config.rc"
+	exit 1
+fi
+
+if [ -f "${BASE_DIR}/../common-functions.sh" ] ; then
+	source "${BASE_DIR}/../common-functions.sh"
+else
+	echo "Missing library: ${BASE_DIR}/../common-functions.sh"
+	exit 1
+fi
+
+if [ -f "${BASE_DIR}/functions.sh" ] ; then
+	source "${BASE_DIR}/functions.sh"
+else
+	echo "Missing: ${BASE_DIR}/functions.sh"
+	exit 1
+fi
+if [ -f "${BASE_DIR}/labels.sh" ] ; then
+	source "${BASE_DIR}/labels.sh"
+else
+	echo "Missing file: ${BASE_DIR}/labels.sh"
+	exit 1
+fi
+
+info "----------------------------------"
+info "Setup..."
+info "----------------------------------"
+
+# load agent
+getAgent
+
+checkFile MooBench "${BASE_DIR}/MooBench.jar"
+checkFile log "${BASE_DIR}/inspectIT.log" clean
+checkDirectory results-directory "${RESULTS_DIR}" recreate
+checkExecutable java "${JAVA_BIN}"
+checkFile R-script "${RSCRIPT_PATH}"
+
+#
+# Run benchmark
+#
+
+info "----------------------------------"
+info "Running benchmark..."
+info "----------------------------------"
 
 TIME=`expr ${METHOD_TIME} \* ${TOTAL_NUM_OF_CALLS} / 1000000000 \* 4 \* ${RECURSION_DEPTH} \* ${NUM_OF_LOOPS} + ${SLEEP_TIME} \* 4 \* ${NUM_OF_LOOPS}  \* ${RECURSION_DEPTH} + 50 \* ${TOTAL_NUM_OF_CALLS} / 1000000000 \* 4 \* ${RECURSION_DEPTH} \* ${NUM_OF_LOOPS} `
 info "Experiment will take circa ${TIME} seconds."
 
-info "Removing and recreating '${RESULTS_DIR}'"
-rm -rf "${RESULTS_DIR}" && mkdir -p "${RESULTS_DIR}"
-
-# Clear inspectit.log and initialize logging
-rm -f "${BASE_DIR}/inspectIT.log"
-touch "${BASE_DIR}/inspectIT.log"
-
 JAVA_ARGS="-server"
 JAVA_ARGS="${JAVA_ARGS} -Xms1G -Xmx2G"
 JAVA_ARGS="${JAVA_ARGS} -verbose:gc "
-JAR="-jar MooBench.jar --application moobench.application.MonitoredClassSimple"
+JAR="-jar ${BASE_DIR}/MooBench.jar --application moobench.application.MonitoredClassSimple"
 
 JAVA_ARGS_NOINSTR="${JAVA_ARGS}"
 JAVA_ARGS_LTW="${JAVA_ARGS} -javaagent:${BASE_DIR}/agent/inspectit-ocelot-agent-1.11.1.jar -Djava.util.logging.config.file=${BASE_DIR}/config/logging.properties"
@@ -133,10 +81,12 @@ JAVA_ARGS_INSPECTIT_NULLWRITER="${JAVA_ARGS_LTW} -Dinspectit.service-name=mooben
 JAVA_ARGS_INSPECTIT_ZIPKIN="${JAVA_ARGS_LTW} -Dinspectit.service-name=moobench-inspectit -Dinspectit.exporters.metrics.prometheus.enabled=false -Dinspectit.exporters.tracing.zipkin.url=http://127.0.0.1:9411/api/v2/spans -Dinspectit.config.file-based.path=${BASE_DIR}/config/zipkin/"
 JAVA_ARGS_INSPECTIT_PROMETHEUS="${JAVA_ARGS_LTW} -Dinspectit.service-name=moobench-inspectit -Dinspectit.exporters.metrics.zipkin.enabled=false -Dinspectit.exporters.metrics.prometheus.enabled=true -Dinspectit.config.file-based.path=${BASE_DIR}/config/prometheus/"
 
-echo "RESULTS_DIR: ${RESULTS_DIR}"
-echo "RAWFN: $RAWFN"
+info "RESULTS_DIR: ${RESULTS_DIR}"
+info "RAWFN: $RAWFN"
 writeConfiguration
 
+info "Ok"
+
 ## Execute Benchmark
 for ((i=1;i<=${NUM_OF_LOOPS};i+=1)); do
     k=0
@@ -167,8 +117,12 @@ mv "${BASE_DIR}/inspectIT.log" "${RESULTS_DIR}/inspectIT.log"
 
 # Create R labels
 LABELS=$(createRLabels)
-run-r
+runR
 
 ## Clean up raw results
 zip -jqr "${RESULTS_DIR}/results.zip" ${RAWFN}*
 rm ${RAWFN}*
+
+info "Done."
+
+# end
diff --git a/frameworks/inspectIT/config.rc b/frameworks/inspectIT/config.rc
new file mode 100644
index 0000000..6bcdafb
--- /dev/null
+++ b/frameworks/inspectIT/config.rc
@@ -0,0 +1,10 @@
+# inspectIT
+
+RSCRIPT_PATH="${BASE_DIR}/../stats.csv.r"
+
+JAVA_BIN="/usr/bin/java"
+
+#MORE_PARAMS="--quickstart"
+
+MORE_PARAMS="${MORE_PARAMS}"
+
diff --git a/frameworks/inspectIT/functions.sh b/frameworks/inspectIT/functions.sh
new file mode 100644
index 0000000..292f5e9
--- /dev/null
+++ b/frameworks/inspectIT/functions.sh
@@ -0,0 +1,114 @@
+# inspectIT specific functions
+
+# ensure the script is sourced
+if [ "${BASH_SOURCE[0]}" -ef "$0" ]
+then
+    echo "Hey, you should source this script, not execute it!"
+    exit 1
+fi
+
+function getAgent() {
+	if [ ! -d "${BASE_DIR}/agent" ] ; then
+		mkdir "${BASE_DIR}/agent"
+		cd "${BASE_DIR}/agent"
+		wget https://github.com/inspectIT/inspectit-ocelot/releases/download/1.11.1/inspectit-ocelot-agent-1.11.1.jar
+		cd "${BASE_DIR}"
+	fi
+}
+
+function runNoInstrumentation {
+    # No instrumentation
+    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
+    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
+    ${JAVA_BIN} ${JAVA_ARGS_NOINSTR} ${JAR} \
+        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
+        --total-calls ${TOTAL_NUM_OF_CALLS} \
+        --method-time ${METHOD_TIME} \
+        --total-threads ${THREADS} \
+        --recursion-depth ${RECURSION_DEPTH} \
+        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
+}
+
+function runInspectITDeactivated {
+    k=`expr ${k} + 1`
+    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
+    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
+    sleep $SLEEP_TIME
+    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_DEACTIVATED} ${JAR} \
+        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
+        --total-calls ${TOTAL_NUM_OF_CALLS} \
+        --method-time ${METHOD_TIME} \
+        --total-threads ${THREADS} \
+        --recursion-depth ${RECURSION_DEPTH} \
+        --force-terminate \
+        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
+    sleep $SLEEP_TIME
+}
+
+function runInspectITNullWriter {
+    k=`expr ${k} + 1`
+    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
+    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
+    sleep $SLEEP_TIME
+    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_NULLWRITER} ${JAR} \
+        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
+        --total-calls ${TOTAL_NUM_OF_CALLS} \
+        --method-time ${METHOD_TIME} \
+        --total-threads ${THREADS} \
+        --recursion-depth ${RECURSION_DEPTH} \
+        --force-terminate \
+        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
+    sleep $SLEEP_TIME
+}
+
+
+function runInspectITZipkin {
+    # InspectIT (minimal)
+    k=`expr ${k} + 1`
+    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
+    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
+    startZipkin
+    sleep $SLEEP_TIME
+    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_ZIPKIN} ${JAR} \
+        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
+        --total-calls ${TOTAL_NUM_OF_CALLS} \
+        --method-time ${METHOD_TIME} \
+        --total-threads ${THREADS} \
+        --recursion-depth ${RECURSION_DEPTH} \
+        --force-terminate \
+        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
+    stopBackgroundProcess
+    sleep $SLEEP_TIME
+}
+
+function runInspectITPrometheus {
+    # InspectIT (minimal)
+    k=`expr ${k} + 1`
+    info " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]}
+    echo " # ${i}.$RECURSION_DEPTH.${k} "${TITLE[$k]} >>${BASE_DIR}/inspectIT.log
+    startPrometheus
+    sleep $SLEEP_TIME
+    ${JAVA_BIN} ${JAVA_ARGS_INSPECTIT_PROMETHEUS} ${JAR} \
+        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
+        --total-calls ${TOTAL_NUM_OF_CALLS} \
+        --method-time ${METHOD_TIME} \
+        --total-threads ${THREADS} \
+        --recursion-depth ${RECURSION_DEPTH} \
+        --force-terminate \
+        ${MORE_PARAMS} &> ${RESULTS_DIR}/output_"$i"_"$RECURSION_DEPTH"_$k.txt
+    stopBackgroundProcess
+    sleep $SLEEP_TIME
+}
+
+function cleanup {
+	[ -f "${BASE_DIR}/hotspot.log" ] && mv "${BASE_DIR}/hotspot.log" "${RESULTS_DIR}/hotspot-${i}-${j}-${k}.log"
+	echo >> "${BASE_DIR}/inspectIT.log"
+	echo >> "${BASE_DIR}/inspectIT.log"
+	sync
+	sleep "${SLEEP_TIME}"
+}
+
+function getSum {
+  awk '{sum += $1; square += $1^2} END {print "Average: "sum/NR" Standard Deviation: "sqrt(square / NR - (sum/NR)^2)" Count: "NR}'
+}
+
diff --git a/frameworks/Kieker/run-benchmark.sh b/run-benchmark.sh
similarity index 100%
rename from frameworks/Kieker/run-benchmark.sh
rename to run-benchmark.sh
-- 
GitLab