#!/bin/csh -f
#
# analyse - analyse the output of GAPS 
# 
# First we strip the comment lines ("-> "). Then we compute the
# ratio of 'y' lines to the total number of references (4000).
# These are plotted in a box plot. We also plot the on/off (yes/no)
# graph for each file.
#

onintr cleanup

cat > plot << EOF
 set samples 4000
 set nokey
 set ytics ("yes" 1,"no" 0)
 plot [:] [0:1.5] "onoff" w lines
EOF

foreach i (out/{lpr,lps,lw,gps,gw,rnd}.*)
    sed '/^-> /d' $i > yn
    set y=`grep 'y$' yn | wc -l`
    set t=`cat yn | wc -l`
    set j=$i:t
    echo $y $t | dm x1/x2 >> ratio.$j:r
    awk '{if ($NF=="y") print NR,1; else print NR, 0; }' yn > onoff
    lasergnu -b -t $i -f plot
end

boxplot -t "ratio of sequential to total refs" ratio.*

cleanup:
rm yn onoff plot
