Kill session daemon after script, conditionally drop caches if root
(else it is forbidden to do so), handle cleanup on trap, use snapshot
(flight recorder) tracing to benchmark ring buffer, output the result in
nanoseconds, removing trailing numbers after dot.
Before this, the test was pretty much always resulting in an output of
"0s" extra overhead due to truncation of significant numbers in the
output.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia7844f3a52821da972b24bf9f39158c24329f63a
: ${PROG_NOTRACING:="./$CURDIR/bench1 $NR_CPUS $NR_EVENTS"}
: ${PROG_TRACING:="./$CURDIR/bench2 $NR_CPUS $NR_EVENTS"}
: ${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
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
time_notrace="$time_notrace+$(sh -c "$CMD_NOTRACING")"
done
lttng-sessiond -d --no-kernel
lttng-sessiond -d --no-kernel
+lttng -q create --snapshot
lttng -q enable-event -u -a
lttng -q start
time_trace=0
for i in $(seq $ITERS); do
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
time_trace="$time_trace+$(sh -c "$CMD_TRACING")"
done
lttng -q stop
lttng -q destroy
-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"