From 0821ab8315d26003a9d43a06e2f87b1b39f43c3b Mon Sep 17 00:00:00 2001
From: Peter Waegemann <waegemann@cs.fau.de>
Date: Tue, 13 Sep 2016 14:16:36 +0200
Subject: [PATCH] Append results of trace-based analysis to dref result files

---
 app/benchmark/timing/all.sh |  4 ++--
 app/benchmark/timing/run    | 37 +++++++++++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/app/benchmark/timing/all.sh b/app/benchmark/timing/all.sh
index 3cf5dc9..c6043ef 100755
--- a/app/benchmark/timing/all.sh
+++ b/app/benchmark/timing/all.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-PWD=$(pwd)
+ALL_PWD=$(pwd)
 cd "$(dirname "$0")"
 
 ./run bench-timing-activate_task 0
@@ -16,4 +16,4 @@ export NO_HEADER=1
 ./run bench-timing-aborted_computation 0
 ./run bench-timing-alarm 0
 
-cd ${PWD}
+cd ${ALL_PWD}
diff --git a/app/benchmark/timing/run b/app/benchmark/timing/run
index ea60dd9..7d6e592 100755
--- a/app/benchmark/timing/run
+++ b/app/benchmark/timing/run
@@ -1,10 +1,21 @@
 #!/bin/bash
 
-cd ../../../build;
+if [ $# -ne 2 ]; then
+  echo "usage: $0 bench-target circuit" >&2
+  exit 1
+fi
 
 BM=$1; shift
 CIRCUIT=$1; shift
 
+RUN_PWD=$(pwd)
+cd "$(dirname "$0")"
+
+cd ../../../build;
+
+# file created by platin's --dref-stats option
+OUTFILE="${BM}.${CIRCUIT}.dref"
+
 echo Building $BM >&2
 make $BM >&2
 
@@ -13,10 +24,32 @@ make wcet-$BM CIRCUIT=$CIRCUIT >&2
 
 # Get numer of states for circuit
 function key() {
-    grep "$1" ${BM}.${CIRCUIT}.dref | sed 's/.*}{//; s/}//'
+    grep "$1" ${OUTFILE} | sed 's/.*}{//; s/}//'
 }
 
 if [ -z "$NO_HEADER" ]; then
     echo -e "Name\tGCFG Nodes\tBound\tIRQs\tTicks\tAlarms"
 fi
 echo -e "${BM}-${CIRCUIT}\t$(key "gcfg nodes")\t$(key "WCA/cycles")\t$(key "WCA/interrupt requests")\t$(key "timer ticks")\t$(key "alarm activations")"
+
+echo Running $BM >&2
+# TRACE_OUTPUT=$(tempfile)
+TRACE_OUTPUT=tempfile.txt
+make test-$BM &> $TRACE_OUTPUT
+
+out_circuit=0
+# iterate over all circuits dumped by the simulation
+for i in $(grep -P timing-[0-9]+ ${TRACE_OUTPUT} | cut -d' ' -f 2); do 
+  
+  # the trace will dump all circuits
+  # However, only the current CIRCUIT is required
+  if [ "${out_circuit}" -eq "${CIRCUIT}" ]; then
+    echo "\drefset{/TRACE/cycles}{" "$i" "}" >> ${OUTFILE}
+  fi
+
+  out_circuit=$(expr ${out_circuit} + 1)
+
+done
+
+cd ${RUN_PWD}
+
-- 
GitLab