occurences_axis.sh 2.93 KB
Newer Older
1 2 3 4 5
#!/bin/bash

xslt=`grep 'xslt' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'`
xquery=`grep 'xquery' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'`

Anthony Lick's avatar
Anthony Lick committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# XSLT queries (total)
total_xslt=0
for file in $xslt
do
  count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath)" $file`
  total_xslt=$(($total_xslt+$count))
done

# Xquery queries (total)
total_xquery=0
for file in $xquery
do
  count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath)" $file`
  total_xquery=$(($total_xquery+$count))
done

# Total queries
total=$(($total_xslt+$total_xquery))

25 26 27 28 29
printf '\\begin{tabular}{lrrr}\n'
printf '\\toprule\n'
printf 'Axis & XSLT & XQuery & Total \\\\\n'
printf '\\midrule\n'

Anthony Lick's avatar
Anthony Lick committed
30
axis_list=("ancestor" "attribute" "child" "descendant" "following" "following-sibling" "namespace" "parent" "preceding" "preceding-sibling" "self")
31 32 33 34 35 36

for axis in ${axis_list[*]}
do
  printf '\\texttt{'
  printf $axis
  printf '}'
Anthony Lick's avatar
Anthony Lick committed
37 38 39
  if [ $axis = "ancestor" ] || [ $axis = "descendant" ]; then
    printf '(\\texttt{-or-self})'
  fi
40 41 42 43 44
  printf ' & '
  # XSLT files
  count_xslt=0
  for file in $xslt
  do
Anthony Lick's avatar
Anthony Lick committed
45
    count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast//xqx:xpathAxis[. = \"$axis\" or . = \"$axis-or-self\"]])" $file`
46 47
    count_xslt=$(($count_xslt+$count))
  done
Anthony Lick's avatar
Anthony Lick committed
48 49
  percent=`echo "scale=1; 100*$count_xslt/$total_xslt" | bc`
  printf $count_xslt' ('%.1f'\\%%)' $percent
50 51 52 53 54
  printf ' & '
  # XQuery files
  count_xquery=0
  for file in $xquery
  do
Anthony Lick's avatar
Anthony Lick committed
55
    count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast//xqx:xpathAxis[. = \"$axis\" or . = \"$axis-or-self\"]])" $file`
56 57
    count_xquery=$(($count_xquery+$count))
  done
Anthony Lick's avatar
Anthony Lick committed
58 59
  percent=`echo "scale=1; 100*$count_xquery/$total_xquery" | bc`
  printf $count_xquery' ('%.1f'\\%%)' $percent
60 61
  printf ' & '
  count_total=$(($count_xslt+$count_xquery))
Anthony Lick's avatar
Anthony Lick committed
62 63
  percent=`echo "scale=1; 100*$count_total/$total" | bc`
  printf $count_total' ('%.1f'\\%%)' $percent
64 65
  printf ' \\\\\n'
done
Anthony Lick's avatar
Anthony Lick committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
printf '\\midrule\n'
printf 'Any axis & '
# XSLT files
count_xslt=0
for file in $xslt
do
  count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast//xqx:xpathAxis])" $file`
  count_xslt=$(($count_xslt+$count))
done
percent=`echo "scale=1; 100*$count_xslt/$total_xslt" | bc`
printf $count_xslt' ('%.1f'\\%%)' $percent
printf ' & '
# XQuery files
count_xquery=0
for file in $xquery
do
  count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast//xqx:xpathAxis])" $file`
  count_xquery=$(($count_xquery+$count))
done
percent=`echo "scale=1; 100*$count_xquery/$total_xquery" | bc`
printf $count_xquery' ('%.1f'\\%%)' $percent
printf ' & '
count_total=$(($count_xslt+$count_xquery))
percent=`echo "scale=1; 100*$count_total/$total" | bc`
printf $count_total' ('%.1f'\\%%)' $percent
printf ' \\\\\n'
92 93
printf '\\bottomrule\n'
printf '\\end{tabular}\n'