From 9bbe4f94cf95cb363e7ddd82dfb7ad446cc818a3 Mon Sep 17 00:00:00 2001
From: Reiner Jung <reiner.jung@email.uni-kiel.de>
Date: Mon, 30 Jan 2023 14:27:06 +0100
Subject: [PATCH] debugging moobench.

---
 common-functions.sh                        | 13 ++++++++++++-
 config.rc                                  |  2 +-
 frameworks/Kieker-java/benchmark.sh        |  6 ++----
 frameworks/Kieker-java/functions.sh        | 19 +++++++++++++++++--
 frameworks/Kieker-python/benchmark.sh      |  2 +-
 frameworks/OpenTelemetry-java/benchmark.sh |  2 +-
 frameworks/inspectIT-java/benchmark.sh     |  2 +-
 upload.sh                                  |  3 +++
 8 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/common-functions.sh b/common-functions.sh
index b21d084..e3fa0fd 100755
--- a/common-functions.sh
+++ b/common-functions.sh
@@ -113,9 +113,17 @@ EOF
 }
 
 function printIntermediaryResults {
+   loop="$1"
    for ((index=0;index<${#TITLE[@]};index+=1)); do
+      RESULT_FILE="${RAWFN}-${loop}-${RECURSION_DEPTH}-${index}.csv"
+      checkFile result "${RESULT_FILE}"
+      raw_length=`cat "${RESULT_FILE}" | wc -l`
+      if [ "${raw_length}" == "0" ] ; then
+         error "Result file '${RESULT_FILE}' is empty."
+         exit 1
+      fi
       info_n "Intermediary results "${TITLE[$index]}" "
-      cat ${RAWFN}-*-${RECURSION_DEPTH}-${index}.csv | awk -F';' '{print $2}' | getSum
+      cat "${RESULT_FILE}" | awk -F';' '{print $2}' | getSum
    done
 }
 
@@ -142,6 +150,9 @@ fi
 
 function error() {
 	echo -e "${ERROR} $@"
+	if [ "${_STOP_ON_ERROR}" == "true" ] ; then
+	   exit 1
+	fi
 }
 
 function warn() {
diff --git a/config.rc b/config.rc
index 9a7859b..5545700 120000
--- a/config.rc
+++ b/config.rc
@@ -1 +1 @@
-experiment.rc
\ No newline at end of file
+test.rc
\ No newline at end of file
diff --git a/frameworks/Kieker-java/benchmark.sh b/frameworks/Kieker-java/benchmark.sh
index 84456b2..b2da6be 100755
--- a/frameworks/Kieker-java/benchmark.sh
+++ b/frameworks/Kieker-java/benchmark.sh
@@ -7,6 +7,7 @@
 
 # configure base dir
 BASE_DIR=$(cd "$(dirname "$0")"; pwd)
+MAIN_DIR="${BASE_DIR}/../.."
 
 #
 # source functionality
@@ -17,8 +18,6 @@ if [ ! -d "${BASE_DIR}" ] ; then
 	exit 1
 fi
 
-MAIN_DIR="${BASE_DIR}/../.."
-
 if [ -f "${MAIN_DIR}/common-functions.sh" ] ; then
 	source "${MAIN_DIR}/common-functions.sh"
 else
@@ -134,8 +133,7 @@ for ((i=1;i<="${NUM_OF_LOOPS}";i+=1)); do
     echo "## Starting iteration ${i}/${NUM_OF_LOOPS}" >> "${DATA_DIR}/kieker.log"
 
     executeBenchmark
-
-    printIntermediaryResults
+    printIntermediaryResults "${i}"
 done
 
 # Create R labels
diff --git a/frameworks/Kieker-java/functions.sh b/frameworks/Kieker-java/functions.sh
index 2492207..676a99c 100644
--- a/frameworks/Kieker-java/functions.sh
+++ b/frameworks/Kieker-java/functions.sh
@@ -50,14 +50,29 @@ function executeExperiment() {
 
     debug "Run options: ${BENCHMARK_OPTS}"
 
+    RESULT_FILE="${RAWFN}-${loop}-${recursion}-${index}.csv"
+    LOG_FILE="${RESULTS_DIR}/output_${loop}_${RECURSION_DEPTH}_${index}.txt"
+
     "${MOOBENCH_BIN}" \
 	--application moobench.application.MonitoredClassSimple \
-        --output-filename "${RAWFN}-${loop}-${recursion}-${index}.csv" \
+        --output-filename "${RESULT_FILE}" \
         --total-calls "${TOTAL_NUM_OF_CALLS}" \
         --method-time "${METHOD_TIME}" \
         --total-threads 1 \
-        --recursion-depth "${recursion}" &> "${RESULTS_DIR}/output_${loop}_${RECURSION_DEPTH}_${index}.txt"
+        --recursion-depth "${recursion}" &> "${LOG_FILE}"
 
+    if [ ! -f "${RESULT_FILE}" ] ; then
+        info "---------------------------------------------------"
+        cat "${LOG_FILE}"
+        error "Result file '${RESULT_FILE}' is empty."
+    else
+       size=`wc -c "${RESULT_FILE}" | awk '{ print $1 }'`
+       if [ "${size}" == "0" ] ; then
+           info "---------------------------------------------------"
+           cat "${LOG_FILE}"
+           error "Result file '${RESULT_FILE}' is empty."
+       fi
+    fi
     rm -rf "${DATA_DIR}"/kieker-*
 
     [ -f "${DATA_DIR}/hotspot.log" ] && mv "${DATA_DIR}/hotspot.log" "${RESULTS_DIR}/hotspot-${loop}-${recursion}-${index}.log"
diff --git a/frameworks/Kieker-python/benchmark.sh b/frameworks/Kieker-python/benchmark.sh
index ca0f175..f2424d1 100755
--- a/frameworks/Kieker-python/benchmark.sh
+++ b/frameworks/Kieker-python/benchmark.sh
@@ -140,7 +140,7 @@ for ((i=1;i<=${NUM_OF_LOOPS};i+=1)); do
     tcpLogging 7 $i 1
     tcpLogging 8 $i 2
     
-    printIntermediaryResults
+    printIntermediaryResults "${i}"
 done
 
 # Create R labels
diff --git a/frameworks/OpenTelemetry-java/benchmark.sh b/frameworks/OpenTelemetry-java/benchmark.sh
index 470410f..e19adf3 100755
--- a/frameworks/OpenTelemetry-java/benchmark.sh
+++ b/frameworks/OpenTelemetry-java/benchmark.sh
@@ -114,7 +114,7 @@ for ((i=1;i<=${NUM_OF_LOOPS};i+=1)); do
     runOpenTelemetryPrometheus
     cleanup
 
-    printIntermediaryResults
+    printIntermediaryResults "${i}"
 done
 
 # Create R labels
diff --git a/frameworks/inspectIT-java/benchmark.sh b/frameworks/inspectIT-java/benchmark.sh
index 4ae88fa..a4da36b 100755
--- a/frameworks/inspectIT-java/benchmark.sh
+++ b/frameworks/inspectIT-java/benchmark.sh
@@ -111,7 +111,7 @@ for ((i=1;i<=${NUM_OF_LOOPS};i+=1)); do
     runInspectITPrometheus
     cleanup
     
-    printIntermediaryResults
+    printIntermediaryResults "${i}"
 done
 
 # Create R labels
diff --git a/upload.sh b/upload.sh
index 07a9541..1cad28e 100755
--- a/upload.sh
+++ b/upload.sh
@@ -11,6 +11,9 @@ BASE_DIR=$(cd "$(dirname "$0")"; pwd)
 KEYSTORE="$1"
 UPDATE_SITE_URL="$2"
 
+error "Upload deactived for debugging purposes."
+exit 1
+
 #
 # source functionality
 #
-- 
GitLab