Commit 4d19294b authored by Anthony LICK's avatar Anthony LICK

Add script for occurences of our grammar

parent 015c49e7
......@@ -31,3 +31,8 @@ transform
treedown
xqtest
xqueryparser
descendant
mark.tar.bz2
xmark
xpathmark-ft
xpathmark-pt
all: dist.dat dist-xquery.dat dist-xslt.dat \
axis-count.tex size-gte-100.tex matrices xslt.dat xqy.dat xslt-std.dat xqy-std.dat coverage-size.tex coverage-axis-step.tex numqueries.tex MAXcount.tex composition.tex composition_full.tex all-full-cov-pc.tex all-full-cov.tex occurences_axis.tex occurences_operators.tex
axis-count.tex size-gte-100.tex matrices xslt.dat xqy.dat xslt-std.dat xqy-std.dat coverage-size.tex coverage-axis-step.tex numqueries.tex MAXcount.tex composition.tex composition_full.tex all-full-cov-pc.tex all-full-cov.tex occurences_axis.tex occurences_operators.tex occurences_grammar.tex
SHELL := /bin/bash
......@@ -139,3 +139,5 @@ occurences_axis.tex: occurences_axis.sh benchmarks-all-full.xml $(wildcard ../..
occurences_operators.tex: occurences_operators.sh benchmarks-all-full.xml $(wildcard ../../benchmark/*-full.xml)
./$< > $@
occurences_grammar.tex: occurences_grammar.sh benchmarks-all-full.xml $(wildcard ../../benchmark/*-full.xml)
./$< > $@
#!/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/'`
# 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))
printf '\\begin{tabular}{lrrr}\n'
printf '\\toprule\n'
printf 'Constructor & XSLT & XQuery & Total \\\\\n'
printf '\\midrule\n'
list=(xpathAxis rootExpr stepExpr predicates unionOp functionCallExpr varRef letExpr forExpr orOp isOp data datap)
legend=('$\\alpha\\dd$' '$/\\pi$' '$\\pi/\\pi$' '$\\pi[\\varphi]$' '$\\pi\\mathrel\\texttt{union}\\pi$' '$f(\\pi_1,\\dots,\\pi_n)$' '$\\mathtt{\\$x}$' '$\\texttt{let}\\:\\mathtt{\\$x}:=\\pi\\mathbin\\texttt{return}\\pi$' '$\\texttt{for}\\:\\mathtt{\\$x}\\mathrel\\texttt{in}\\pi\\mathrel\\texttt{return}\\pi$' '$\\varphi\\mathrel\\texttt{or}\\varphi,~\\varphi\\mathrel\\texttt{and}\\varphi$' '$\\pi\\mathrel\\texttt{is}\\pi$' '$\\pi\\mathbin\\triangle\\pi$' '$\\pi\\mathbin{\\trianglep}d$')
n=`echo ${#list[@]}`
for (( i=0; i<$n; i++))
do
name=`echo ${list[$i]}`
printf ${legend[$i]}
printf ' & '
# XSLT files
count_xslt=0
for file in $xslt
do
if [ $name = "stepExpr" ]; then
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast//xqx:stepExpr/following-sibling::*[1 and self::xqx:stepExpr]])" $file`
elif [ $name = "forExpr" ]; then
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast[.//xqx:forExpr or .//xqx:quantifiedExpr]])" $file`
elif [ $name = "orOp" ]; then
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast[.//xqx:orOp or .//xqx:andOp]])" $file`
elif [ $name = "data" ]; then
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast[.//xqx:eqOp or .//xqx:neOp]])" $file`
elif [ $name = "datap" ]; then
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast[.//xqx:eqOp or .//xqx:neOp or .//xqx:leOp or .//xqx:ltOp or .//xqx:geOp or .//xqx:gtOp]])" $file`
else
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast//xqx:$name])" $file`
fi
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
if [ $name = "forExpr" ]; then
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast[.//xqx:forExpr or .//xqx:quantifiedExpr]])" $file`
else
count=`xmlstarlet sel -N xqx="http://www.w3.org/2005/XQueryX" -t -c "count(/benchmark/xpath[ast//xqx:$name])" $file`
fi
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'
done
printf '\\bottomrule\n'
printf '\\end{tabular}\n'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment