# run ust benchmark
#
+iters=20
+NR_EVENTS=7000000
+NR_CPUS=1
+
+TIME="./ptime"
+
+#PROG_NOMARKER="find /usr"
+PROG_NOMARKER="./bench1 $NR_CPUS $NR_EVENTS"
+#PROG_MARKER=$PROG_NOMARKER
+PROG_MARKER="./bench2 $NR_CPUS $NR_EVENTS"
+
+CMD_NOMARKER="$TIME '$PROG_NOMARKER >/dev/null 2>&1'"
+CMD_MARKER="$TIME '$PROG_MARKER >/dev/null 2>&1'"
+CMD_MARKERCONN="UST_AUTOPROBE=1 $TIME '$PROG_MARKER >/dev/null 2>&1'"
+CMD_MARKERTRACE="UST_TRACE=1 UST_AUTOPROBE=1 UST_OVERWRITE=1 UST_AUTOCOLLECT=0 $TIME '$PROG_MARKER >/dev/null 2>&1'"
+
echo "ust benchmark"
-NR_EVENTS=4000000
-NR_CPUS=2
+rm -f result-*.txt average-*.txt perevent-*.txt
+
echo "using $NR_CPUS processor(s)"
echo "using $NR_EVENTS events per cpu"
+n=0
+while [ $n -lt "$iters" ]; do
+ # without markers
+ echo ">running without markers"
+ echo 3 >/proc/sys/vm/drop_caches
+ t1=$(sh -c "$CMD_NOMARKER")
+ echo "$t1" >>result-nomark.txt
+ echo " time=$t1 sec"
+ n=$(($n+1))
+done
+./average <result-nomark.txt >average-nomark.txt
-rm -f /tmp/bench.txt
-# without markers
-echo ">running without markers"
-#t1=$(/usr/bin/time -f%e usttrace ./bench1 $NR_CPUS $NR_EVENTS 2>&1 1> /dev/null)
-t1=$(/usr/bin/time -f%e ./bench1 $NR_CPUS $NR_EVENTS 2>&1 1> /dev/null)
-echo " time=$t1 sec"
+## with markers, not connected
+#n=0
+#while [ $n -lt "$iters" ]; do
+# echo ">running with markers, not connected"
+# echo 3 >/proc/sys/vm/drop_caches
+# t2=$(sh -c "$CMD_MARKER")
+# echo "$t2" >>result-mark.txt
+# echo " time=$t2 sec"
+# n=$(($n+1))
+#done
+#./average <result-mark.txt >average-mark.txt
+#echo "( $(<average-mark.txt) - $(<average-nomark.txt) ) / $NR_EVENTS" | bc -l >perevent-mark.txt
+## with markers, connected
+#n=0
+#while [ $n -lt "$iters" ]; do
+# echo ">running with markers activated"
+# echo 3 >/proc/sys/vm/drop_caches
+# t2=$(sh -c "$CMD_MARKERCONN")
+# echo "$t2" >>result-markconn.txt
+# echo " time=$t2 sec"
+# n=$(($n+1))
+#done
+#./average <result-markconn.txt >average-markconn.txt
+#echo "( $(<average-markconn.txt) - $(<average-nomark.txt) ) / $NR_EVENTS" | bc -l >perevent-markconn.txt
-rm -f /tmp/bench.txt
-# with markers
-echo ">running with markers activated"
-t2=$(/usr/bin/time -f%e usttrace ./bench2 $NR_CPUS $NR_EVENTS 2>&1 1> /dev/null)
-echo " time=$t2 sec"
+# with markers, connected, tracing
+n=0
+while [ $n -lt "$iters" ]; do
+ echo ">running with markers activated, trace recording"
+ echo 3 >/proc/sys/vm/drop_caches
+ t3=$(sh -c "$CMD_MARKERTRACE")
+ echo "$t3" >>result-marktrace.txt
+ echo " time=$t3 sec"
+ n=$(($n+1))
+done
+./average <result-marktrace.txt >average-marktrace.txt
+echo "( $(<average-marktrace.txt) - $(<average-nomark.txt) ) / $NR_EVENTS" | bc -l >perevent-marktrace.txt
+
+function print_penalty()
+{
+ echo ""
+
+ #penalty = t2 - t1
+ penalty=$(echo "$2 - $1;" | bc)
+ echo "Penalty ($3) = $penalty sec"
+ #event = penalty / (nr_events * nr_cpus)
+ event=$(echo "scale=10; ($penalty / ($NR_EVENTS * $NR_CPUS));" | bc)
+ echo "Penalty per event ($3) = $event sec"
+}
-#penalty = t2 - t1
-echo
-penalty=$(echo "$t2 - $t1;" | bc)
-echo "time penalty=$penalty sec"
+#print_penalty $t1 $t2 "Penalty for markers enabled, not tracing"
+#print_penalty $t1 $t3 "Penalty for markers enabled, tracing"
-#event = penalty / (nr_events * nr_cpus)
-event=$(echo "scale=10; ($penalty / ($NR_EVENTS * $NR_CPUS));" | bc)
-echo "time penalty per event=$event sec"
rm -f /tmp/bench.txt