| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2020 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
| 4 | # |
| 5 | # SPDX-License-Identifier: MIT |
| 6 | |
| 7 | EVENT_NAME_HIT=performance:hit |
| 8 | EVENT_NAME_RECEIVE=performance:receive |
| 9 | TRIGGER_NAME=performance_hit |
| 10 | |
| 11 | if [ -z "$1" ]; then |
| 12 | echo "missing source id int value" |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | if [ -z "$2" ]; then |
| 17 | echo "missing trace directory name" |
| 18 | exit 1 |
| 19 | fi |
| 20 | |
| 21 | if [ -z "$3" ]; then |
| 22 | echo "missing loop delay" |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | if [ -z "$4" ]; then |
| 27 | echo "missing loop count" |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | key_id="$1" |
| 32 | trace_directory="$(pwd)/trace/$2" |
| 33 | delay=$3 |
| 34 | count=$4 |
| 35 | |
| 36 | if ! lttng list > /dev/null 2>&1 ; then |
| 37 | echo "Could not connect to session daemon, are you sure it is running?" |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | lttng create performance --output="$trace_directory" |
| 42 | lttng enable-event -u $EVENT_NAME_HIT,$EVENT_NAME_RECEIVE -s performance |
| 43 | lttng start |
| 44 | |
| 45 | filter="source==$key_id" |
| 46 | lttng add-trigger --id ${TRIGGER_NAME} --condition on-event --userspace $EVENT_NAME_HIT --filter="$filter" --action notify |
| 47 | |
| 48 | ./consumer "$key_id" "$count" $TRIGGER_NAME & |
| 49 | |
| 50 | # Cheap way to synchronize and ensure that the consumer is ready to consume |
| 51 | sleep 2 |
| 52 | |
| 53 | ./producer "$key_id" "$count" "$delay" & |
| 54 | |
| 55 | wait |
| 56 | |
| 57 | lttng remove-trigger ${TRIGGER_NAME} |
| 58 | |
| 59 | lttng stop |
| 60 | lttng destroy performance |
| 61 | |