: ${PROG_NOTRACING:="./$CURDIR/bench1 $NR_CPUS $NR_EVENTS"}
: ${PROG_TRACING:="./$CURDIR/bench2 $NR_CPUS $NR_EVENTS"}
+function signal_cleanup ()
+{
+ killall lttng-sessiond
+}
+
+trap signal_cleanup SIGTERM SIGINT
+
CMD_NOTRACING="$TIME '$PROG_NOTRACING >/dev/null 2>&1'"
CMD_TRACING="$TIME '$PROG_TRACING >/dev/null 2>&1'"
time_notrace=0
for i in $(seq $ITERS); do
- echo 3 >/proc/sys/vm/drop_caches
+ if [[ $EUID -eq 0 ]]; then
+ echo 3 >/proc/sys/vm/drop_caches
+ fi
time_notrace="$time_notrace+$(sh -c "$CMD_NOTRACING")"
done
+
lttng-sessiond -d --no-kernel
-lttng -q create
+lttng -q create --snapshot
lttng -q enable-event -u -a
lttng -q start
time_trace=0
for i in $(seq $ITERS); do
- echo 3 >/proc/sys/vm/drop_caches
+ if [[ $EUID -eq 0 ]]; then
+ echo 3 >/proc/sys/vm/drop_caches
+ fi
time_trace="$time_trace+$(sh -c "$CMD_TRACING")"
done
lttng -q stop
lttng -q destroy
+killall lttng-sessiond
pass "Trace benchmark"
-diag "Average tracing overhead per event is $(echo "scale=6;( ($time_trace) - ($time_notrace) ) / $ITERS / $NR_EVENTS" | bc -l)s"
+S_PER_EVENT=$(echo "( ($time_trace) - ($time_notrace) ) / $ITERS / $NR_EVENTS" | bc -l)
+NS_PER_EVENT=$(echo "$S_PER_EVENT * 1000000000" | bc -l)
+# Remove fractions
+NS_PER_EVENT=${NS_PER_EVENT%%.*}
+
+diag "Average tracing overhead per event is ${NS_PER_EVENT}ns"