occurences_axis.sh 2.84 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 30 31 32 33 34 35 36 37 38 39 40 41
printf '\\begin{tabular}{lrrr}\n'
printf '\\toprule\n'
printf 'Axis & XSLT & XQuery & Total \\\\\n'
printf '\\midrule\n'

axis_list=("ancestor" "attribute" "child" "descendant" "following" "following-sibling" "namespace" "parent" "descendant" "preceding" "preceding-sibling" "self")

for axis in ${axis_list[*]}
do
  printf '\\texttt{'
  printf $axis
  printf '}'
  printf ' & '
  # XSLT files
  count_xslt=0
  for file in $xslt
  do
Anthony Lick's avatar
Anthony Lick committed
42
    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`
43 44
    count_xslt=$(($count_xslt+$count))
  done
Anthony Lick's avatar
Anthony Lick committed
45 46
  percent=`echo "scale=1; 100*$count_xslt/$total_xslt" | bc`
  printf $count_xslt' ('%.1f'\\%%)' $percent
47 48 49 50 51
  printf ' & '
  # XQuery files
  count_xquery=0
  for file in $xquery
  do
Anthony Lick's avatar
Anthony Lick committed
52
    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`
53 54
    count_xquery=$(($count_xquery+$count))
  done
Anthony Lick's avatar
Anthony Lick committed
55 56
  percent=`echo "scale=1; 100*$count_xquery/$total_xquery" | bc`
  printf $count_xquery' ('%.1f'\\%%)' $percent
57 58
  printf ' & '
  count_total=$(($count_xslt+$count_xquery))
Anthony Lick's avatar
Anthony Lick committed
59 60
  percent=`echo "scale=1; 100*$count_total/$total" | bc`
  printf $count_total' ('%.1f'\\%%)' $percent
61 62
  printf ' \\\\\n'
done
Anthony Lick's avatar
Anthony Lick committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
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'
89 90
printf '\\bottomrule\n'
printf '\\end{tabular}\n'