]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - wme_test/plot
Added -o option to plot command. Renamed some variables.
[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:eso: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         s) SET_TERM_TEMPLATE='set term svg enhanced; set output "${FILE}.svg"';;
13         o) MULTIPDF_FILENAME=$OPTARG;;
14         p)
15             SET_TERM_TEMPLATE='set term postscript color landscape enhanced'
16             PDF_OUTPUT=1
17             ;;
18         P)
19             SET_TERM_TEMPLATE='set term postscript color landscape enhanced'
20             MULTIPLE_GRAPHS_IN_PDF=1
21             GNUPLOT_CMD_FILE=plot_commands.$$
22             rm -f ${GNUPLOT_CMD_FILE}
23             ;;
24     esac
25 done
26
27 shift $(($OPTIND - 1))
28
29 [ $# -eq 0 -a -r delay_stats.dat ] && set delay_stats.dat
30
31
32 while [ $# -gt 0 ];
33 do
34     FILE=`basename "$1" .dat`
35     shift
36
37     COMMAND="Results of: $(grep 'Invoked as' ${FILE}.dat|grep -o 'wclient.*'|sed -e 's/ -o [^ ]*//' -e 's/ [^ ]* ?$//')"
38     STREAMS="$(grep '^#' ${FILE}.dat|sed -ne '2,$ s/^# //p'|while read LINE; do echo {/*0.7 $LINE}\\n; done|tr -d '\n'|sed -e 's/_/\\\\_/g')"
39
40     TITLE="${COMMAND}\n\n${STREAMS}"
41
42     SET_TERM=$(echo $SET_TERM_TEMPLATE|sed -e s/\${FILE}/$FILE/)
43     if [ -n "$MULTIPLE_GRAPHS_IN_PDF" ]; then
44         CMD="cat >>$GNUPLOT_CMD_FILE"
45     elif [ -n "$PDF_OUTPUT" ]; then
46         CMD="cat | gnuplot | ps2pdf - ${FILE}.pdf"
47     else 
48         CMD="cat | gnuplot -persist"
49     fi
50     eval $CMD <<EOF
51 ${SET_TERM}
52 set xlabel "Response-Time [ms]"
53 set ylabel "Cumulative % of packets"
54 set title "${TITLE}"
55 set key right bottom nobox
56 set style data linespoints
57 set grid
58 plot $DELAY_BOUND \
59      "${FILE}.dat" index 0 title "AC\\\\_VO",\
60      "${FILE}.dat" index 1 title "AC\\\\_VI",\
61      "${FILE}.dat" index 2 title "AC\\\\_BE",\
62      "${FILE}.dat" index 3 title "AC\\\\_BK"
63 EOF
64 done
65
66 if [ -n "$MULTIPLE_GRAPHS_IN_PDF" ]; then
67     gnuplot $GNUPLOT_CMD_FILE|ps2pdf - $MULTIPDF_FILENAME
68     rm -f $GNUPLOT_CMD_FILE
69 fi