From 7786d1420ffc0a25b1d39ef81144f193524f0760 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Fri, 20 Apr 2012 15:27:31 +0200 Subject: [PATCH] Add performance regression test script. --- tests/scripts/check_perf.sh | 117 ++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 tests/scripts/check_perf.sh diff --git a/tests/scripts/check_perf.sh b/tests/scripts/check_perf.sh new file mode 100755 index 0000000..d077aad --- /dev/null +++ b/tests/scripts/check_perf.sh @@ -0,0 +1,117 @@ +#!/bin/bash + + +function usage(){ + echo "$0 " + +} + +if [ -z "$1" -o ! -f "$1" ] +then + usage + exit 1 +fi + +DOC="$1" + +FILENAME=`basename "$DOC"` +FILENAME=`echo "$FILENAME" | sed -e 's/\.srx/\.xml/'` +REFERENCE=tests/perf_tests/"$FILENAME".best +QUERIES=tests/perf_tests/"$FILENAME".queries + +function cecho() { + case "$1" in + green) + START="\033[0;32m" + END="\033[0m" + ;; + yellow) + START="\033[1;33m" + END="\033[0m" + ;; + red) + START="\033[0;31m" + END="\033[0m" + ;; + *) + START="" + END="" + ;; + esac + echo -n -e "${START}${2}${END}" +} + +function getline(){ + FILE="$1" + I="$2" + cat "$FILE" | tail -n +"$I" | head -n 1 +} + + + +I=1 + +while read Q +do +echo "Query $I" +echo "$Q" +REF=`getline "$REFERENCE" "$I"` +RCOUNT=`echo "$REF" | cut -f 2 -d ,` +RTCOUNT=`echo "$REF" | cut -f 3 -d ,` +RTMAT=`echo "$REF" | cut -f 4 -d ,` + +./main.native -r 1 -d -c "$DOC" "$Q" > tmp 2>&1 +TCOUNT=`cat tmp | grep 'Execution time' | grep -o '[0-9]\+\.[0-9]*' | sort -g | head -1` +CCOUNT=`cat tmp | grep 'Number of results' | grep -o '[0-9]\+'` + +./main.native -r 1 -d "$DOC" "$Q" > tmp 2>&1 +TMAT=`cat tmp | grep 'Execution time' | grep -o '[0-9]\+\.[0-9]*' | sort -g | head -1` +MCOUNT=`cat tmp | grep 'Number of results' | grep -o '[0-9]\+'` + +rm -f tmp +I=$(($I + 1)) + +if [ "$MCOUNT" != "$CCOUNT" ] +then + echo "Count mismatch between counting and materialization ! ($MCOUNT, $CCOUNT)" + echo + continue +fi + +if [ "$MCOUNT" != "$RCOUNT" -a "$RCOUNT" ] +then + echo "Count mismatch between current and reference implementation!" + echo + continue +fi + +CSPEED=`echo '5k 1 ' "$TCOUNT" "$RTCOUNT" ' / - p' | dc` +echo -n "Reference counting time: $RTCOUNT, Current counting time: $TCOUNT, " +case $CSPEED in + -.0*) + cecho yellow "slow-down: $CSPEED" + ;; + -*) cecho red "slow-down: $CSPEED" + ;; + *) + cecho green "speed-up: $CSPEED" + ;; +esac +echo + +MSPEED=`echo '5k 1 ' "$TMAT" "$RTMAT" ' / - p' | dc` +echo -n "Reference mat. time: $RTMAT, Current mat. time: $TMAT, " +case $MSPEED in + -.0*) + cecho yellow "slow-down: $MSPEED" + ;; + -*) cecho red "slow-down: $MSPEED" + ;; + *) + cecho green "speed-up: $MSPEED" + ;; +esac +echo +echo + +done < "$QUERIES" -- 2.17.1