]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - wme_test/plot
No fixed ranges in plot, so we can zoom in an interactive mode.
[frescor/fwp.git] / wme_test / plot
1 #!/bin/sh
2
3 SET_TERM_TEMPLATE='set term push; set term x11 enhanced; set term wxt enhanced; set term pop'
4
5 DELAY_BOUND="[]"
6
7 while getopts d:esp opt
8 do
9     case $opt in
10         d) DELAY_BOUND="[0:$OPTARG]";;
11         e) SET_TERM_TEMPLATE='set term postscript color eps enhanced; set output "${FILE}.eps"';;
12         s) SET_TERM_TEMPLATE='set term svg enhanced; set output "${FILE}.svg"';;
13         p)
14             SET_TERM_TEMPLATE='set term postscript color landscape enhanced'
15             PDF_OUTPUT=1
16             ;;
17         P)
18             SET_TERM_TEMPLATE='set term postscript color landscape enhanced'
19             SINGLE_PDF=1
20             GNUPLOT_CMD_FILE=plot_commands.$$
21             rm -f ${GNUPLOT_CMD_FILE}
22             ;;
23     esac
24 done
25
26 shift $(($OPTIND - 1))
27
28 [ $# -eq 0 -a -r delay_stats.dat ] && set delay_stats.dat
29
30
31 while [ $# -gt 0 ];
32 do
33     FILE=`basename "$1" .dat`
34     shift
35
36     COMMAND="Results of: $(grep 'Invoked as' ${FILE}.dat|grep -o 'wclient.*'|sed -e 's/ -o [^ ]*//' -e 's/ [^ ]* ?$//')"
37     STREAMS="$(grep -o 'Stream.*' ${FILE}.dat|sort|while read LINE; do echo {/*0.7 $LINE}\\n; done|tr -d '\n'|sed -e 's/_/\\\\_/g')"
38
39     TITLE="${COMMAND}\n\n${STREAMS}"
40
41     SET_TERM=$(echo $SET_TERM_TEMPLATE|sed -e s/\${FILE}/$FILE/)
42     if [ -n "$SINGLE_PDF" ]; then
43         CMD="cat >>$GNUPLOT_CMD_FILE"
44     elif [ -n "$PDF_OUTPUT" ]; then
45         CMD="cat | gnuplot | ps2pdf - ${FILE}.pdf"
46     else 
47         CMD="cat | gnuplot -persist"
48     fi
49     eval $CMD <<EOF
50 ${SET_TERM}
51 set xlabel "Delay [ms]"
52 set ylabel "Cumulative % of packets"
53 set title "${TITLE}"
54 set key right bottom nobox
55 set style data linespoints
56 set grid
57 plot $DELAY_BOUND \
58      "${FILE}.dat" index 0 title "AC\\\\_VO",\
59      "${FILE}.dat" index 1 title "AC\\\\_VI",\
60      "${FILE}.dat" index 2 title "AC\\\\_BE",\
61      "${FILE}.dat" index 3 title "AC\\\\_BK"
62 EOF
63 done
64
65 if [ -n "$SINGLE_PDF" ]; then
66     gnuplot $GNUPLOT_CMD_FILE|ps2pdf - all.pdf
67     rm -f $GNUPLOT_CMD_FILE
68 fi