occurences_axis.sh 3.07 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))

Sylvain Schmitz's avatar
Sylvain Schmitz committed
25
printf '\\begin{tabular}{lr@{\\hspace{1pt}}rr@{\\hspace{1pt}}rr@{\\hspace{1pt}}r}\n'
26
printf '\\toprule\n'
Sylvain Schmitz's avatar
Sylvain Schmitz committed
27
printf 'Axis & \\multicolumn{2}{c}{XSLT} & \\multicolumn{2}{c}{XQuery} & \\multicolumn{2}{c}{Total} \\\\\n'
28 29
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
  percent=`echo "scale=1; 100*$count_xslt/$total_xslt" | bc`
Sylvain Schmitz's avatar
Sylvain Schmitz committed
49
  printf "%'.0f & (%.1f\\%%)" $count_xslt $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
  percent=`echo "scale=1; 100*$count_xquery/$total_xquery" | bc`
Sylvain Schmitz's avatar
Sylvain Schmitz committed
59
  printf "%'.0f & (%.1f\\%%)" $count_xquery $percent
60 61
  printf ' & '
  count_total=$(($count_xslt+$count_xquery))
Anthony Lick's avatar
Anthony Lick committed
62
  percent=`echo "scale=1; 100*$count_total/$total" | bc`
Sylvain Schmitz's avatar
Sylvain Schmitz committed
63
  printf "%'.0f & (%.1f\\%%)" $count_total $percent
64 65
  printf ' \\\\\n'
done
Anthony Lick's avatar
Anthony Lick committed
66
printf '\\midrule\n'
Sylvain Schmitz's avatar
Sylvain Schmitz committed
67
printf 'All axes & '
Anthony Lick's avatar
Anthony Lick committed
68 69 70 71 72 73 74 75
# 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`
Sylvain Schmitz's avatar
Sylvain Schmitz committed
76
printf "%'.0f & (%.1f\\%%)" $count_xslt $percent
Anthony Lick's avatar
Anthony Lick committed
77 78 79 80 81 82 83 84 85
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`
Sylvain Schmitz's avatar
Sylvain Schmitz committed
86
printf "%'.0f & (%.1f\\%%)" $count_xquery $percent
Anthony Lick's avatar
Anthony Lick committed
87 88 89
printf ' & '
count_total=$(($count_xslt+$count_xquery))
percent=`echo "scale=1; 100*$count_total/$total" | bc`
Sylvain Schmitz's avatar
Sylvain Schmitz committed
90
printf "%'.0f & (%.1f\\%%)" $count_total $percent
Anthony Lick's avatar
Anthony Lick committed
91
printf ' \\\\\n'
92 93
printf '\\bottomrule\n'
printf '\\end{tabular}\n'