]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - wme_test/plot
Delete all -o flags from title of graph.
[frescor/fwp.git] / wme_test / plot
1 #!/usr/bin/perl -w
2 use Getopt::Std;
3 use File::Basename;
4
5 # Default values
6 $SET_TERM_TEMPLATE='set term push; set term x11 enhanced; set term wxt enhanced; set term pop';
7 $DELAY_BOUND="[]";
8 $MULTIPDF_FILENAME="all.pdf";
9
10 # Process command line options
11 my %opt;
12 getopts('bd:enso:pP', \%opt);
13
14 $PLOT_BOTH_DIRECTIONS=1 if $opt{'b'};
15 $DELAY_BOUND="[0:".$opt{'d'}."]" if $opt{'d'};
16 $SET_TERM_TEMPLATE='set term postscript color eps enhanced; set output "${FILE}.eps"' if $opt{'e'};
17 $SET_TERM_TEMPLATE='set term png enhanced; set output "${FILE}.png"' if $opt{'n'};
18 $SET_TERM_TEMPLATE='set term svg enhanced; set output "${FILE}.svg"' if $opt{'s'};
19 $MULTIPDF_FILENAME=$opt{'o'} if $opt{'o'};
20 if ($opt{'p'}) {
21     $SET_TERM_TEMPLATE='set term postscript color landscape enhanced';
22     $PDF_OUTPUT=1;
23 }
24 if ($opt{'P'}) {
25     $SET_TERM_TEMPLATE='set term postscript color landscape enhanced';
26     $MULTIPLE_GRAPHS_IN_PDF=1;
27     $GNUPLOT_CMD_FILE="plot_commands.$$";
28     unlink ${GNUPLOT_CMD_FILE};
29 }
30
31 if ($#ARGV < 0 && -r "delay_stats.dat") {$ARGV[0]="delay_stats.dat";}
32
33 # Process the data files and plot graph(s)
34 foreach $dat_file (@ARGV) {
35     ($FILE, , ) = fileparse($dat_file, (".dat"));
36
37     # Get labels from data file
38     $COMMAND="";
39     $STREAMS="";
40     open F, $dat_file;
41     while (<F>) {
42         if (/wclient.*/) {
43             $_=$&;
44             s/ -o [^ ]*//g;
45             $COMMAND="Results of: $_";
46             #$COMMAND="Results of: grep -o 'wclient.*'|sed -e 's/ -o [^ ]*//' -e 's/ [^ ]* ?$//')"
47         } elsif (/^#[^#] */) {
48             $STREAMS .= "$'";
49         }
50         
51         
52     }
53     close F;
54     $STREAMS =~ s/\n/\\n/g;
55
56     if ($MULTIPLE_GRAPHS_IN_PDF) {
57         open CMD, ">>$GNUPLOT_CMD_FILE";
58     } elsif ($PDF_OUTPUT) {
59         open CMD, "| gnuplot | ps2pdf - ${FILE}.pdf";
60     } else {
61         open CMD, "| gnuplot -persist";
62     }
63 #     close CMD;
64 #     open CMD, ">&STDOUT";
65     $SET_TERM = $SET_TERM_TEMPLATE;
66     $SET_TERM =~ s/\${FILE}/$FILE/;
67
68     print CMD qq/
69 ${SET_TERM}
70 set xlabel "Response-Time [ms]"
71 set ylabel "Cumulative % of packets"
72 set key right bottom nobox
73 set style data linespoints
74 #set logscale x
75 set grid
76 set size 1,0.8
77 unset label
78 set label "${COMMAND}" noenhanced at graph 0,1.3
79 set label "${STREAMS}" noenhanced at graph 0,1.2 font "Helvetica,9"
80 set style line 1  lt 1 lc rgb "red"
81 set style line 2  lt 1 lc rgb "green"
82 set style line 3  lt 1 lc rgb "blue"
83 set style line 4  lt 1 lc rgb "magenta"
84 set style line 5  lt 2 lc rgb "red" lw 2
85 set style line 6  lt 2 lc rgb "green" lw 2
86 set style line 7  lt 2 lc rgb "blue" lw 2
87 set style line 8  lt 2 lc rgb "magenta" lw 2
88 set style line 9  lt 3 lc rgb "red" lw 2
89 set style line 10 lt 3 lc rgb "green" lw 2
90 set style line 11 lt 3 lc rgb "blue" lw 2
91 set style line 12 lt 3 lc rgb "magenta" lw 2
92 /;
93
94     print CMD qq/plot $DELAY_BOUND [0.01:100]\\
95      "${FILE}.dat" index 0 with linespoints ls 1 title "AC\\\\_VO",\\
96      "${FILE}.dat" index 1 with linespoints ls 2 title "AC\\\\_VI",\\
97      "${FILE}.dat" index 2 with linespoints ls 3 title "AC\\\\_BE",\\
98      "${FILE}.dat" index 3 with linespoints ls 4 title "AC\\\\_BK"/;
99
100     if ($PLOT_BOTH_DIRECTIONS) {
101         print CMD qq/,\\
102      "${FILE}.dat" index 0 using 1:3 with lines ls 5  title "AC\\\\_VO cs",\\
103      "${FILE}.dat" index 1 using 1:3 with lines ls 6  title "AC\\\\_VI cs",\\
104      "${FILE}.dat" index 2 using 1:3 with lines ls 7  title "AC\\\\_BE cs",\\
105      "${FILE}.dat" index 3 using 1:3 with lines ls 8  title "AC\\\\_BK cs",\\
106      "${FILE}.dat" index 0 using 1:4 with lines ls 9  title "AC\\\\_VO sc",\\
107      "${FILE}.dat" index 1 using 1:4 with lines ls 10 title "AC\\\\_VI sc",\\
108      "${FILE}.dat" index 2 using 1:4 with lines ls 11 title "AC\\\\_BE sc",\\
109      "${FILE}.dat" index 3 using 1:4 with lines ls 12 title "AC\\\\_BK sc"
110 /;
111     } else {
112         print CMD "\n";
113     }
114     close CMD;
115 }
116
117 if ($MULTIPLE_GRAPHS_IN_PDF) {
118     system("gnuplot $GNUPLOT_CMD_FILE|ps2pdf - $MULTIPDF_FILENAME");
119     unlink ${GNUPLOT_CMD_FILE};
120 }