Rename directory non_regression_tests to comparison_tests
[SXSI/xpathcomp.git] / tests / comparison_tests / test.sh
diff --git a/tests/comparison_tests/test.sh b/tests/comparison_tests/test.sh
new file mode 100755 (executable)
index 0000000..40ddcd4
--- /dev/null
@@ -0,0 +1,151 @@
+#!/bin/bash
+I=1
+
+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 lessthan() {
+    echo '5k 1 st 0 sf' "$2" "$1" '<t ' "$2" "$1" '!<f p' | dc
+}
+
+
+if [ "$1" = "fast" ]
+then
+    repeat_monet=1
+    repeat_sxsi=1
+    repeat_qizx=2
+else
+    repeat_monet=1
+    repeat_sxsi=10
+    repeat_qizx=4
+fi
+
+
+for TESTDOC in medline_full.xml #"xmark_10.xml"  #"medline.xml" "xmark_01.04.xml"
+do
+echo
+echo "$TESTDOC"
+echo
+
+MLOG="$TESTDOC"_monet.log
+SLOG="$TESTDOC"_sxsi.log
+QLOG="$TESTDOC"_qizx.log
+rm -f "$MLOG" "$SLOG" "$QLOG"
+cat "$TESTDOC".queries | grep -v '^#' | while read line
+do
+
+    qname=`echo "$line" | cut -f 1 -d "%"`
+    query=`echo "$line" | cut -f 2 -d "%"`
+    query_qizx=`echo "$line" | cut -f 3 -d "%"`
+    if [ -z "$query_qizx" ]
+    then
+       query_qizx="$query"
+    fi
+    echo Test $I "... "
+    echo "$query" | sed -e 's|/descendant::|//|g' | sed -e 's|child::||g'
+    echo -n Running SXSI
+    {
+       read sxsi_count_time
+       read sxsi_mat_time
+       read sxsi_print_time
+       read sxsi_count
+    } < <(`pwd`/sxsi.sh "$query" "$TESTDOC" "$repeat_sxsi" "$2")
+
+    echo " ok"
+    echo -n Running MonetBD/XQuery
+
+    if [ "$query" = '/descendant::people[ descendant::person[not(child::address)] and descendant::person[not(child::watches)]]/child::person[child::watches]' ]
+    then
+       #Quick work around since MonetBD fails on q11
+       monet_count_time=1000000
+       monet_mat_time=1000000
+       monet_print_time=1000000
+       monet_count="$sxsi_count"
+    else
+    {
+       read monet_count_time
+       read monet_mat_time
+       read monet_print_time
+       read monet_count
+    } < <(`pwd`/monet.sh "$query" "$TESTDOC" "$repeat_monet" "$2")
+
+    fi
+    echo " ok"
+
+    echo -n Running Qizx/XQuery
+    {
+       read qizx_count_time
+       read qizx_mat_time
+       read qizx_print_time
+       read qizx_count
+    } < <(`pwd`/qizx.sh "$query_qizx" "$TESTDOC" "$repeat_qizx" "$2")
+
+    echo " ok"
+
+    if [ "$monet_count" = "" ]
+    then
+       monet_count="$sxsi_count"
+    fi
+    if [ "$sxsi_count" = "" ]
+    then
+       sxsi_count="$monet_count"
+    fi
+    for v in sxsi_count_time sxsi_mat_time sxsi_print_time \
+       monet_count_time monet_mat_time monet_print_time \
+       qizx_count_time qizx_mat_time qizx_print_time
+    do
+       if [ "${!v}" = "" ]
+       then
+           { read "$v"; } < <( echo 7200000 )
+       fi
+    done
+
+
+
+    echo "$I,$sxsi_count,$sxsi_count_time,$sxsi_mat_time,$sxsi_print_time" >> "$SLOG"
+    echo "$I,$monet_count,$monet_count_time,$monet_mat_time,$monet_print_time" >>"$MLOG"
+    echo "$I,$qizx_count,$qizx_count_time,$qizx_mat_time,$qizx_print_time" >>"$QLOG"
+    echo -n "Correctness: "
+    if [ "$monet_count" = "$sxsi_count" ]
+    then
+       cecho green "count ok ($monet_count) "
+    else
+       cecho red "count error (monetdb: $monet_count, sxsi: $sxsi_count) "
+    fi
+    echo
+    echo -n "Timing: "
+    CTIME="SXSI: $sxsi_count_time
+MONET: $monet_count_time
+QIZX: $qizx_count_time"
+    SORTED_CTIME=`echo "$CTIME" | sort --key=2 -g`
+    STR_CTIME=`echo "$SORTED_CTIME" | xargs echo -n`
+    first=`echo "$STR_CTIME" | cut -f1 -d':'`
+    if [ "$first" = "SXSI" ]
+    then
+       cecho green "$STR_CTIME"
+    else
+       cecho yellow "$STR_CTIME"
+    fi
+    I=$(( $I + 1))
+    echo
+done
+done