]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - wme_test/plot
Plot script reworked to have test aligned.
[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:enso:pP 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         n) SET_TERM_TEMPLATE='set term png enhanced; set output "${FILE}.png"';;
13         s) SET_TERM_TEMPLATE='set term svg enhanced; set output "${FILE}.svg"';;
14         o) MULTIPDF_FILENAME=$OPTARG;;
15         p)
16             SET_TERM_TEMPLATE='set term postscript color landscape enhanced'
17             PDF_OUTPUT=1
18             ;;
19         P)
20             SET_TERM_TEMPLATE='set term postscript color landscape enhanced'
21             MULTIPLE_GRAPHS_IN_PDF=1
22             GNUPLOT_CMD_FILE=plot_commands.$$
23             rm -f ${GNUPLOT_CMD_FILE}
24             ;;
25     esac
26 done
27
28 shift $(($OPTIND - 1))
29
30 [ $# -eq 0 -a -r delay_stats.dat ] && set delay_stats.dat
31
32
33 while [ $# -gt 0 ];
34 do
35     FILE=`basename "$1" .dat`
36     shift
37
38     COMMAND="Results of: $(grep 'Invoked as' ${FILE}.dat|grep -o 'wclient.*'|sed -e 's/ -o [^ ]*//' -e 's/ [^ ]* ?$//')"
39     STREAMS="$(grep '^#' ${FILE}.dat|sed -ne '2,$ s/^# //p'|while read LINE; do echo $LINE\\n; done|tr -d '\n')"
40
41     SET_TERM=$(echo $SET_TERM_TEMPLATE|sed -e s/\${FILE}/$FILE/)
42     if [ -n "$MULTIPLE_GRAPHS_IN_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 "Response-Time [ms]"
52 set ylabel "Cumulative % of packets"
53 set key right bottom nobox
54 set style data linespoints
55 #set logscale x
56 set grid
57 set size 1,0.8
58 set label "${COMMAND}" noenhanced at graph 0,1.3
59 set label "${STREAMS}" noenhanced at graph 0,1.2 font "helv,6"
60 plot $DELAY_BOUND \
61      "${FILE}.dat" index 0 title "AC\\\\_VO",\
62      "${FILE}.dat" index 1 title "AC\\\\_VI",\
63      "${FILE}.dat" index 2 title "AC\\\\_BE",\
64      "${FILE}.dat" index 3 title "AC\\\\_BK"
65 EOF
66 done
67
68 if [ -n "$MULTIPLE_GRAPHS_IN_PDF" ]; then
69     gnuplot $GNUPLOT_CMD_FILE|ps2pdf - $MULTIPDF_FILENAME
70     rm -f $GNUPLOT_CMD_FILE
71 fi