distribution.sh 798 Bytes
Newer Older
Sylvain Schmitz's avatar
Sylvain Schmitz committed
1
#!/bin/bash
2 3
# count the number of queries of each size
# argument: the size of blocks of queries, 1 by default
Sylvain Schmitz's avatar
Sylvain Schmitz committed
4

5 6 7 8 9 10
if [ "$#" -ne 1 ]
then
    step=1
else
    step=$1
fi
11
fragments=`grep 'type="\(xslt\|xquery\)"' benchmarks-all-full.xml | sed -e 's/.*href="\([^"]*\).*/\1/'`
Sylvain Schmitz's avatar
Sylvain Schmitz committed
12 13
MAX=`grep 'MAX_AST_SIZE =' ../../src/main/java/fr/lsv/xpparser/XPathEntry.java| sed -e 's/[^0-9]*\([0-9]*\).*/\1/'`

Sylvain Schmitz's avatar
Sylvain Schmitz committed
14 15 16
numqueries=`cat numqueries`
half=$((numqueries / 2))
total=0
17
for ((i = 1; i < $MAX; i+=$step))
Sylvain Schmitz's avatar
Sylvain Schmitz committed
18
do
19 20 21 22 23 24
    C=0
    for ((j = $i; j < $i+$step; ++j))
    do
        G=`grep "ast depth=.* size=\"$j\"" $fragments | wc -l`
        C=$((C + G))
    done
Sylvain Schmitz's avatar
Sylvain Schmitz committed
25 26 27 28 29 30 31
    total=$((C + total))
    if [ "$total" -gt "$half" ]
    then
        printf "%'.0f" $i > median.tex
        half=$numqueries
    fi
    echo "$i $C $total"
Sylvain Schmitz's avatar
Sylvain Schmitz committed
32 33
done