coverage-size.sh 2.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/bash
# compute coverage table of benchmark results by size
# with rows = `accepted by at least one full fragment'
# and  cols = `query size'
# using list of files provided on command-line

MAX=`grep 'MAX_AST_SIZE =' ../../src/main/java/fr/lsv/xpparser/XPathEntry.java| sed -e 's/[^0-9]*\([0-9]*\).*/\1/'`
fragments=( `grep 'file=' ../../relaxng/fragments-full.xml | sed 's/.*file=\"\([\.a-zA-Z0-9\-]*.rnc\).*/\1/g'` )
step=4
cutoff=48

full="(@schema=\"${fragments[0]}\")"
for ((f = 1; f < ${#fragments[@]}; ++f))
do
    full="$full or (@schema=\"${fragments[f]}\")"
done


# header
printf '\\begin{tabular}{l'
for ((i = 1; i < $cutoff; i+=$step))
do
    printf 'r'
done
25
printf 'r}\n\\toprule\n'
26 27 28 29 30 31 32
printf 'sizes '
for ((i = 1; i < $cutoff; i+=$step))
do
    printf "& $i--$((i+step-1)) "
done
printf "& $\ge $i$"
printf '\\\\\n'
33
printf '\\midrule\n'
34 35 36 37 38 39 40 41 42 43 44 45

# number of queries of each size
printf 'queries '
for ((i = 1; i < $cutoff; i+=$step))
do
    value=0
    for file in $@
    do
        count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $i and @size < ($i+$step)])])" $file`
        value=$((count + value))
    done
    array[$i]=$value
Sylvain Schmitz's avatar
Sylvain Schmitz committed
46
    printf "& %'.0f " ${array[i]}
47 48 49 50 51 52 53 54
done
value=0
for file in $@
do
    count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $i])])" $file`
    value=$((count + value))
done
array[$i]=$value
Sylvain Schmitz's avatar
Sylvain Schmitz committed
55
printf "& %'.0f" $value
56 57 58 59 60 61 62 63 64 65 66 67
printf '\\\\\n'

# first row: accepted
printf 'coverage '
for ((i = 1; i < $cutoff; i+=$step))
do
    value=0
    for file in $@
    do
        count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $i and @size < ($i+$step)]) and (schemas/validation[($full) and @valid=\"yes\"])])" $file`
        value=$((count + value))
    done
Sylvain Schmitz's avatar
Sylvain Schmitz committed
68
    percent=`echo "scale=1; 100*$value/${array[i]}" | bc`
69 70 71 72 73 74 75 76
    printf "& $percent\\%% "
done
value=0
for file in $@
do
    count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(//xpath[(ast[@size >= $i]) and (schemas/validation[($full) and @valid=\"yes\"])])" $file`
    value=$((count + value))
done
Sylvain Schmitz's avatar
Sylvain Schmitz committed
77
percent=`echo "scale=1; 100*$value/${array[i]}" | bc`
78 79
printf "& $percent\\%% "
printf '\\\\\n'
80
printf '\\bottomrule\n'
81
printf '\\end{tabular}\n'