Here is a simple script for A/B testing. Just modify the CONFIG section to your needs, or feel free to rewrite completely 🙂
#! /bin/bash
# ========== CONFIG ==========
# make sure the commands output no information text
# the first command, the benchmark
CMD1="nohup sox -q /home/pavel/audio/441.wav -t alsa plughw:0 &
sudo chrt -f -p 40 \$!"
DESC[1]="CHRT40"
# the second command, to be compared with
CMD2="nohup sox -q /home/pavel/audio/441.wav -t alsa plughw:0 &
sudo chrt -f -p 58 \$!"
DESC[2]="CHRT58"
# number of runs
RUNS=10
# delay between each command
DELAY=1s
# ========= END OF CONFIG =======
LABEL1="Listen to ${DESC[1]} now"
LABEL2="Listen now and guess if ${DESC[1]} or ${DESC[2]}"
QUESTION="Did you hear (1) ${DESC[1]} or (2) ${DESC[2]}?"
function valid() {
        lANSWER=$1
        if [ "x$lANSWER" = "x1" ] || [ "x$lANSWER" = "x2" ]; then
                return 0
        else
                return 1
        fi
}
for RUN in $(seq 1 $RUNS); do
        echo ""
        echo "Run $RUN"
        echo "--------"
        echo $LABEL1
        sleep $DELAY
        eval $CMD1 &>/dev/null
        wait
        sleep $DELAY
        echo $LABEL2
        ALT=$(( $RANDOM % 2 + 1))
        REAL[$RUN]=$ALT
        if [[ $ALT = 1 ]]; then
                eval $CMD1 &>/dev/null
                wait
        else
                eval $CMD2 &>/dev/null
                wait
        fi
        ANSWER=0
        until valid $ANSWER; do
                echo
                echo "$QUESTION"
                read ANSWER
        done
        echo "Thank you."
        PERCEIVED[$RUN]=$ANSWER
done
echo
echo
echo "Results:"
echo -e "RUN\tWAS\tANSWER"
echo "----------------------------"
HITS=0
for RUN in $(seq 1 $RUNS); do
        echo -e "$RUN:\t${DESC[${REAL[$RUN]}]}\t${DESC[${PERCEIVED[$RUN]}]}"
        if [ ${REAL[$RUN]} = ${PERCEIVED[$RUN]} ]; then
                let "HITS += 1"
        fi
done
echo
echo "Correct answers: $HITS, i.e. $(( $HITS * 100 / $RUNS))%"