From ecff4abc7e2d500413cc673ec27044a6d9f99deb Mon Sep 17 00:00:00 2001 From: David Georg Reichelt <davidgeorg_reichelt@dagere.de> Date: Sun, 18 Jul 2021 15:22:52 +0200 Subject: [PATCH] Extract methods for better readability --- frameworks/opentelemetry/benchmark.sh | 235 +++++++++++++------------- 1 file changed, 120 insertions(+), 115 deletions(-) diff --git a/frameworks/opentelemetry/benchmark.sh b/frameworks/opentelemetry/benchmark.sh index 5b05a31..1f06816 100755 --- a/frameworks/opentelemetry/benchmark.sh +++ b/frameworks/opentelemetry/benchmark.sh @@ -22,7 +22,7 @@ function startPrometheus { rm prometheus-2.28.1.linux-amd64.tar.gz fi cd prometheus-2.28.1.linux-amd64 - ./prometheus > prometheus.log & + ./prometheus &> prometheus.log & cd .. } @@ -35,7 +35,7 @@ function startJaeger { rm jaeger-1.24.0-linux-amd64.tar.gz fi cd jaeger-1.24.0-linux-amd64 - ./jaeger-all-in-one > jaeger.log & + ./jaeger-all-in-one &> jaeger.log & cd .. } @@ -43,6 +43,107 @@ function stopBackgroundProcess { kill %1 } +function cleanup { + [ -f ${BASEDIR}hotspot.log ] && mv ${BASEDIR}hotspot.log ${RESULTSDIR}hotspot-${i}-${j}-${k}.log + echo >>${BASEDIR}opentelemetry.log + echo >>${BASEDIR}opentelemetry.log + sync + sleep ${SLEEPTIME} +} + +function runNoInstrumentation { + # No instrumentation + k=`expr ${k} + 1` + echo " # ${i}.${j}.${k} No instrumentation" + echo " # ${i}.${j}.${k} No instrumentation" >>${BASEDIR}opentelemetry.log + ${JAVABIN}java ${JAVAARGS_NOINSTR} ${JAR} \ + --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ + --total-calls ${TOTALCALLS} \ + --method-time ${METHODTIME} \ + --total-threads ${THREADS} \ + --recursion-depth ${j} \ + ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_uninstrumented.txt +} + +function runOpenTelemetryNoLogging { + # OpenTelemetry Instrumentation Logging Deactivated + k=`expr ${k} + 1` + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging Deactivated" + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging Deactivated" >>${BASEDIR}opentelemetry.log + ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_LOGGING_DEACTIVATED} ${JAR} \ + --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ + --total-calls ${TOTALCALLS} \ + --method-time ${METHODTIME} \ + --total-threads ${THREADS} \ + --recursion-depth ${j} \ + ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry.txt +} + +function runOpenTelemetryLogging { + # OpenTelemetry Instrumentation Logging + k=`expr ${k} + 1` + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging" + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging" >>${BASEDIR}opentelemetry.log + ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_LOGGING} ${JAR} \ + --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ + --total-calls ${TOTALCALLS} \ + --method-time ${METHODTIME} \ + --total-threads ${THREADS} \ + --recursion-depth ${j} \ + ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_logging.txt + if [ ! "$DEBUG" = true ] + then + rm ${RESULTSDIR}output_"$i"_opentelemetry_logging.txt + fi +} + +function runOpenTelemetryZipkin { + # OpenTelemetry Instrumentation Zipkin + k=`expr ${k} + 1` + startZipkin + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Zipkin" + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Zipkin" >>${BASEDIR}opentelemetry.log + ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_ZIPKIN} ${JAR} \ + --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ + --total-calls ${TOTALCALLS} \ + --method-time ${METHODTIME} \ + --total-threads ${THREADS} \ + --recursion-depth ${j} \ + ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_zipkin.txt + stopBackgroundProcess +} + +function runOpenTelemetryJaeger { + # OpenTelemetry Instrumentation Jaeger + k=`expr ${k} + 1` + startJaeger + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Jaeger" + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Jaeger" >>${BASEDIR}opentelemetry.log + ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_JAEGER} ${JAR} \ + --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ + --total-calls ${TOTALCALLS} \ + --method-time ${METHODTIME} \ + --total-threads ${THREADS} \ + --recursion-depth ${j} \ + ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_prometheus.txt + stopBackgroundProcess +} + +function runOpenTelemetryPrometheus { + # OpenTelemetry Instrumentation Prometheus + k=`expr ${k} + 1` + startPrometheus + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Prometheus" + echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Prometheus" >>${BASEDIR}opentelemetry.log + ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_PROMETHEUS} ${JAR} \ + --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ + --total-calls ${TOTALCALLS} \ + --method-time ${METHODTIME} \ + --total-threads ${THREADS} \ + --recursion-depth ${j} \ + ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_prometheus.txt + stopBackgroundProcess +} function getSum { awk '{sum += $1; square += $1^2} END {print "Average: "sum/NR" Standard Deviation: "sqrt(square / NR - (sum/NR)^2)" Count: "NR}' @@ -67,8 +168,9 @@ function printIntermediaryResults { echo -n "Intermediary results opentelemetry Jaeger" cat tmp/results-opentelemetry/raw-*-$RECURSIONDEPTH-5.csv | awk -F';' '{print $2}' | getSum - echo -n "Intermediary results opentelemetry Prometheus" - cat tmp/results-opentelemetry/raw-*-$RECURSIONDEPTH-6.csv | awk -F';' '{print $2}' | getSum + # Prometheus does not work currently + #echo -n "Intermediary results opentelemetry Prometheus" + #cat tmp/results-opentelemetry/raw-*-$RECURSIONDEPTH-6.csv | awk -F';' '{print $2}' | getSum fi } @@ -114,7 +216,7 @@ JAR="-jar MooBench.jar" if [ ! -f "MooBench.jar" ] then - echo "MooBench.jar missing; please build it first using ./gradlew assemble in the main folder" + echo "MooBench.jar missing; please build it first using ../gradlew assemble in the benchmark folder" exit 1 fi @@ -156,124 +258,27 @@ for ((i=1;i<=${NUM_LOOPS};i+=1)); do echo "## Starting iteration ${i}/${NUM_LOOPS}" echo "## Starting iteration ${i}/${NUM_LOOPS}" >>${BASEDIR}opentelemetry.log - # No instrumentation - k=`expr ${k} + 1` - echo " # ${i}.${j}.${k} No instrumentation" - echo " # ${i}.${j}.${k} No instrumentation" >>${BASEDIR}opentelemetry.log - #sar -o ${RESULTSDIR}stat/sar-${i}-${j}-${k}.data 5 2000 1>/dev/null 2>&1 & - ${JAVABIN}java ${JAVAARGS_NOINSTR} ${JAR} \ - --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ - --total-calls ${TOTALCALLS} \ - --method-time ${METHODTIME} \ - --total-threads ${THREADS} \ - --recursion-depth ${j} \ - ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_uninstrumented.txt - #kill %sar - [ -f ${BASEDIR}hotspot.log ] && mv ${BASEDIR}hotspot.log ${RESULTSDIR}hotspot-${i}-${j}-${k}.log - echo >>${BASEDIR}opentelemetry.log - echo >>${BASEDIR}opentelemetry.log - sync - sleep ${SLEEPTIME} + runNoInstrumentation + cleanup - # OpenTelemetry Instrumentation Logging Deactivated - k=`expr ${k} + 1` - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging Deactivated" - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging Deactivated" >>${BASEDIR}opentelemetry.log - #sar -o ${RESULTSDIR}stat/sar-${i}-${j}-${k}.data 5 2000 1>/dev/null 2>&1 & - ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_LOGGING_DEACTIVATED} ${JAR} \ - --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ - --total-calls ${TOTALCALLS} \ - --method-time ${METHODTIME} \ - --total-threads ${THREADS} \ - --recursion-depth ${j} \ - ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry.txt - #kill %sar - [ -f ${BASEDIR}hotspot.log ] && mv ${BASEDIR}hotspot.log ${RESULTSDIR}hotspot-${i}-${j}-${k}.log - echo >>${BASEDIR}opentelemetry.log - echo >>${BASEDIR}opentelemetry.log - sync - sleep ${SLEEPTIME} + runOpenTelemetryNoLogging + cleanup - # OpenTelemetry Instrumentation Logging - k=`expr ${k} + 1` - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging" - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Logging" >>${BASEDIR}opentelemetry.log - ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_LOGGING} ${JAR} \ - --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ - --total-calls ${TOTALCALLS} \ - --method-time ${METHODTIME} \ - --total-threads ${THREADS} \ - --recursion-depth ${j} \ - ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_logging.txt - [ -f ${BASEDIR}hotspot.log ] && mv ${BASEDIR}hotspot.log ${RESULTSDIR}hotspot-${i}-${j}-${k}.log - echo >>${BASEDIR}opentelemetry.log - echo >>${BASEDIR}opentelemetry.log - if [ ! "$DEBUG" = true ] - then - rm ${RESULTSDIR}output_"$i"_opentelemetry_logging.txt - fi - sync - sleep ${SLEEPTIME} + runOpenTelemetryLogging + cleanup - # OpenTelemetry Instrumentation Zipkin - k=`expr ${k} + 1` - startZipkin - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Zipkin" - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Zipkin" >>${BASEDIR}opentelemetry.log - ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_ZIPKIN} ${JAR} \ - --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ - --total-calls ${TOTALCALLS} \ - --method-time ${METHODTIME} \ - --total-threads ${THREADS} \ - --recursion-depth ${j} \ - ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_zipkin.txt - [ -f ${BASEDIR}hotspot.log ] && mv ${BASEDIR}hotspot.log ${RESULTSDIR}hotspot-${i}-${j}-${k}.log - echo >>${BASEDIR}opentelemetry.log - echo >>${BASEDIR}opentelemetry.log - stopBackgroundProcess - sync - sleep ${SLEEPTIME} + runOpenTelemetryZipkin + cleanup MACHINE_TYPE=`uname -m`; if [ ${MACHINE_TYPE} == 'x86_64' ] then - # OpenTelemetry Instrumentation Jaeger - k=`expr ${k} + 1` - startPrometheus - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Jaeger" - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Jaeger" >>${BASEDIR}opentelemetry.log - ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_JAEGER} ${JAR} \ - --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ - --total-calls ${TOTALCALLS} \ - --method-time ${METHODTIME} \ - --total-threads ${THREADS} \ - --recursion-depth ${j} \ - ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_prometheus.txt - [ -f ${BASEDIR}hotspot.log ] && mv ${BASEDIR}hotspot.log ${RESULTSDIR}hotspot-${i}-${j}-${k}.log - echo >>${BASEDIR}opentelemetry.log - echo >>${BASEDIR}opentelemetry.log - stopBackgroundProcess - sync - sleep ${SLEEPTIME} + runOpenTelemetryJaeger + cleanup - # OpenTelemetry Instrumentation Prometheus - k=`expr ${k} + 1` - startPrometheus - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Prometheus" - echo " # ${i}.${j}.${k} OpenTelemetry Instrumentation Prometheus" >>${BASEDIR}opentelemetry.log - ${JAVABIN}java ${JAVAARGS_OPENTELEMETRY_PROMETHEUS} ${JAR} \ - --output-filename ${RAWFN}-${i}-${j}-${k}.csv \ - --total-calls ${TOTALCALLS} \ - --method-time ${METHODTIME} \ - --total-threads ${THREADS} \ - --recursion-depth ${j} \ - ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_opentelemetry_prometheus.txt - [ -f ${BASEDIR}hotspot.log ] && mv ${BASEDIR}hotspot.log ${RESULTSDIR}hotspot-${i}-${j}-${k}.log - echo >>${BASEDIR}opentelemetry.log - echo >>${BASEDIR}opentelemetry.log - stopBackgroundProcess - sync - sleep ${SLEEPTIME} + # Prometheus does not work currently + #runOpenTelemetryPrometheus + #cleanup else echo "No 64 Bit System; skipping Prometheus" fi -- GitLab