composition.sh 3.09 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/'`

6
printf '\\begin{tabular}{lrrrrr}\n'
7
printf '\\toprule\n'
Sylvain Schmitz's avatar
Sylvain Schmitz committed
8 9
printf '\\multicolumn{1}{c}{Sources} & \\multicolumn{1}{c}{Queries} & \\multicolumn{4}{c}{Coverage}\\\\\n'
printf ' & & \\multicolumn{1}{c}{XPath\\,1.0} & \\multicolumn{1}{c}{XPath\\,2.0} & \\multicolumn{1}{c}{XPath\,3.0} & \\multicolumn{1}{c}{XPath\,3.0\,std}\\\\\n'
10 11 12
printf '\\midrule\n'

# total number of XSLT queries
Anthony LICK's avatar
Anthony LICK committed
13
printf 'XSLT '
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
n=`grep '<ast' $xslt | wc -l`
printf "& %'.0f " $n
#coverage of standard XPath languages
for ((i=1; i < 4; ++i))
do
    count=0
    for file in $xslt
    do
        c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-$i.0.rnc\" and @valid=\"yes\"]])" $file`
        count=$((count+c))
    done
    counts[$i]=$count
    percent=`echo "scale=1; 100*$count/$n" | bc`
    printf "& $percent\\\\%% "
done
29 30 31 32 33 34 35 36 37
count=0
for file in $xslt
do
    c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-3.0-std.rnc\" and @valid=\"yes\"]])" $file`
    count=$((count+c))
done
counts[4]=$count
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
Anthony LICK's avatar
Anthony LICK committed
38
printf '\\\\\n'
39 40 41

N=$n
# total number of XQuery queries
Anthony LICK's avatar
Anthony LICK committed
42
printf 'XQuery '
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
n=`grep '<ast' $xquery | wc -l`
printf "& %'.0f " $n
# coverage of standard XPath languages
for ((i=1; i < 4; ++i))
do
    count=0
    for file in $xquery
    do
        c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-$i.0.rnc\" and @valid=\"yes\"]])" $file`
        count=$((count+c))
    done
    counts[$i]=$((count + counts[i]))
    percent=`echo "scale=1; 100*$count/$n" | bc`
    printf "& $percent\\\\%% "
done
58 59 60 61 62 63 64 65 66
count=0
for file in $xquery
do
    c=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[schemas/validation[@schema=\"xpath-3.0-std.rnc\" and @valid=\"yes\"]])" $file`
    count=$((count+c))
done
counts[4]=$((count + counts[4]))
percent=`echo "scale=1; 100*$count/$n" | bc`
printf "& $percent\\\\%% "
Anthony LICK's avatar
Anthony LICK committed
67
printf '\\\\\n'
68 69 70 71 72

N=$((N + n))
printf '\\midrule\n'
printf 'Total '
printf "& %'.0f " $N
73
for ((i=1; i < 5; ++i))
74 75 76 77 78
do
    count=${counts[i]}
    percent=`echo "scale=1; 100*$count/$N" | bc`
    printf "& $percent\\\\%% "
done
Anthony LICK's avatar
Anthony LICK committed
79
printf '\\\\\n'
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

printf '\\bottomrule\n'
printf '\\end{tabular}\n'


# \begin{tabular}{lrrrr}
#     \toprule
#     Source & \!\!queries & \!\!XPath\,1.0 & \!\!XPath\,2.0 & \!\!XPath\,3.0\\
#     % \midrule
#     % W3C QT     & 207 & 132 & 138 & 207\\
#     % XPathMark & 38 & 38 & 38 & 38\\
#     \midrule
#     DocBook & 7,620 & 7,620 & 7,620 & 7,620 \\
#     HTMLBook & 752 & 752 & 752 & 752 \\
#     eXist-db & 1,236 & 955 & 1,105 & 1,236 \\
#     HisTEI & 483 & 361 & 471 & 483 \\
#     MarkLogic & 196 & 139 & 184 & 191 \\
#     XQJSON & 90 & 67 & 90 & 90 \\
#     \midrule
#     Total & 10,377 & 9,894 & 10,222 & 10,372\\
#           &        & (95\%) & (98\%)  & (100\%)\\
#     \bottomrule
# \end{tabular}