Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/plot_bars.sh

Issue 1237903003: Modified histogram shell plot script, added python dynamics plot script (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/bin/bash
2
3 # Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
4 #
5 # Use of this source code is governed by a BSD-style license
6 # that can be found in the LICENSE file in the root of the source
7 # tree. An additional intellectual property rights grant can be found
8 # in the file PATENTS. All contributing project authors may
9 # be found in the AUTHORS file in the root of the source tree.
10
11 # To set up in e.g. Eclipse, run a separate shell and pipe the output from the
12 # test into this script.
13 #
14 # In Eclipse, that amounts to creating a Run Configuration which starts
15 # "/bin/bash" with the arguments "-c [trunk_path]/out/Debug/modules_unittests
16 # --gtest_filter=*BweTest* | [trunk_path]/webrtc/modules/
17 # remote_bitrate_estimator/test/plot_bars.sh
18
19 # This script supports multiple figures (windows), the figure is specified as an
20 # identifier at the first argument after the PLOT command. Each figure has a
21 # single y axis and a dual y axis mode. If any line specifies an axis by ending
22 # with "#<axis number (1 or 2)>" two y axis will be used, the first will be
23 # assumed to represent bitrate (in kbps) and the second will be assumed to
24 # represent time deltas (in ms).
25
26 log=$(</dev/stdin)
27
28 # Plot histograms.
29 function gen_gnuplot_bar_input {
30 x_start=1
31 x_end=3.75
32 bars=$(echo "$log" | grep "BAR")
33
34 labels=$(echo "$log" | grep "^LABEL")
35 figures=($(echo "$bars" | cut -f 2 | sort | uniq))
36
37 echo "reset"
38
39 echo "set title font 'Verdana,22'"
40 echo "set xtics font 'Verdana,24'"
41 echo "set ytics font 'Verdana,14'"
42 echo "set ylabel font 'Verdana,16'"
43
44 echo "set xrange[$x_start:$x_end]"
45 echo "set style fill solid 0.5"
46 echo "set style fill solid border -1"
47
48 ydist=11 # Used to correctly offset the y label.
49 for figure in "${figures[@]}" ; do
50
51 echo "set terminal wxt $figure size 440,440 dashed"
52 echo "set ylabel offset $ydist, -3"
53 ((ydist--))
54
55 title=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 3 | \
56 head -n 1 | sed 's/_/ /g')
57 y_label=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 4 | \
58 head -n 1 | sed 's/_/ /g')
59
60 # RMCAT flows.
61 num_flows=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 5 | \
62 head -n 1)
63
64 # RMCAT algorithm 1.
65 x_label_1=$(echo "$log" | grep "BAR.$figure" | cut -f 3 | sed 's/_/\t/g' \
66 | cut -f 1 | sort | uniq | head -n 1 )
67
68 # RMCAT algorithm 2.
69 x_label_2=$(echo "$log" | grep "BAR.$figure" | cut -f 3 | sed 's/_/\t/g' \
70 | cut -f 1 | sort | uniq | sed -n 2p)
71
72 x_labels="('$x_label_1' 2, '$x_label_2' 3)"
73 tcp_flow=false
74
75 tcp_space=0.2 # Extra horizontal space between bars.
76
77 # Parse labels if there are other flows in addition to RMCAT ones.
78 IFS='x' read -ra split_label_1 <<< "$x_label_1"
79
80 if (( ${#split_label_1[@]} > "1" )); then
81 tcp_flow=true
82 box_width=$(echo "(1.0-$tcp_space/2)/$num_flows" | bc -l)
83 echo "set xtics font 'Verdana,16'"
84 x_labels="("
85 delimiter=""
86 abscissa=$(echo $x_start + 0.5 + 0.5*$box_width | bc)
87 for label in "${split_label_1[@]}" ; do
88 x_labels+="$delimiter'$label' $abscissa"
89 abscissa=$(echo $abscissa + $box_width | bc)
90 delimiter=", "
91 done
92 abscissa=$(echo $abscissa + $tcp_space | bc)
93 IFS='x' read -ra split_label_2 <<< "$x_label_2"
94 for label in "${split_label_2[@]}" ; do
95 x_labels+="$delimiter'$label' $abscissa"
96 abscissa=$(echo $abscissa + $box_width | bc)
97 done
98 x_labels="$x_labels)"
99 else
100 box_width=$(echo 1.0/$num_flows | bc -l)
101 fi
102
103 echo "set boxwidth $box_width"
104
105 # Plots can be directly exported to image files.
106 file_name=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 5 | head -n 1)
107
108 y_max=0 # Used to scale the plot properly.
109
110 # Since only the optimal bitrate for the first flow is being ploted,
111 # consider only this one for scalling purposes.
112 data_sets=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | cut -f 3 | \
113 sed 's/_/\t/g' | cut -f 1 | sort | uniq)
114
115 if (( ${#data_sets} > "0" )); then
116 for set in $data_sets ; do
117 y=$(echo "$bars" | grep "LIMITERRORBAR.$figure.$set" | cut -f 8 | \
118 head -n 1)
119 if (( $(bc <<< "$y > $y_max") == 1 )); then
120 y_max=$y
121 fi
122 done
123 fi
124
125 data_sets=$(echo "$bars" | grep "ERRORBAR.$figure" | cut -f 3 | sort | uniq)
126 if (( ${#data_sets} > "0" )); then
127 for set in $data_sets ; do
128 y=$(echo "$bars" | grep "ERRORBAR.$figure.$set" | cut -f 6 | head -n 1)
129 if (( $(bc <<< "$y > $y_max") == 1 )) ; then
130 y_max=$y
131 fi
132 done
133 fi
134
135 data_sets=$(echo "$bars" | grep "BAR.$figure" | cut -f 3 | sort | uniq)
136
137 for set in $data_sets ; do
138 y=$(echo "$bars" | grep "BAR.$figure.$set" | cut -f 4 | head -n 1)
139 if (( $(bc <<< "$y > $y_max") == 1 )) ; then
140 y_max=$y
141 fi
142 done
143
144 y_max=$(echo $y_max*1.1 | bc)
145
146 # Scale all latency plots with the same vertical scale.
147 delay_figure=5
148 if (( $figure==$delay_figure )) ; then
149 y_max=250
150 fi
151
152 echo "set ylabel \"$y_label\""
153 echo "set yrange[0:$y_max]"
154
155 echo "set multiplot"
156
157 # Plot bars.
158 data_sets=$(echo "$bars" | grep "BAR.$figure" | cut -f 3 | sort | uniq)
159
160 echo "set xtics $x_labels"
161 echo "plot '-' using 1:4:2 with boxes lc variable notitle"
162
163 echo
164
165 color=11 # Green.
166 x_bar=$(echo $x_start + 0.5 + 0.5*$box_width | bc)
167 for set in $data_sets ; do
168 echo -n "$x_bar $color "
169 echo "$bars" | grep "BAR.$figure.$set" | cut -f 3,4
170
171 # Add extra space if TCP flows are being plotted.
172 if $tcp_flow && \
173 (( $(bc <<< "$x_bar < $x_start + 1.5 - 0.5*$tcp_space") == 1 )) && \
174 (( $(bc <<< "$x_bar + $box_width > $x_start + 1.5 + 0.5*$tcp_space") \
175 == 1 )); then
176 x_bar=$(echo $x_bar + $tcp_space | bc)
177 fi
178
179 x_bar=$(echo $x_bar + $box_width | bc)
180
181 if (( $(bc <<< "$x_bar > 2.5") == 1 )) ; then
182 color=12 # Blue.
183 fi
184 # Different bar color for TCP flows:
185 if $tcp_flow && \
186 (( $(bc <<< "(100*$x_bar)%100 < 50") == 1 ))
187 then
188 color=18 # Gray.
189 fi
190 done
191 echo "e"
192
193 # Plot Baseline bars, e.g. one-way path delay on latency plots.
194 data_sets=$(echo "$log" | grep "BASELINE.$figure" | cut -f 3 | sort | uniq)
195
196 echo "set xtics $x_labels"
197 echo "plot '-' using 1:4:2 with boxes lc variable notitle"
198
199 echo
200
201 color=18 # Gray.
202 x_bar=$(echo $x_start + 0.5 + 0.5*$box_width | bc)
203 for set in $data_sets ; do
204 echo -n "$x_bar $color "
205 echo "$log" | grep "BASELINE.$figure.$set" | cut -f 3,4
206
207 # Add extra space if TCP flows are being plotted.
208 if $tcp_flow && \
209 (( $(bc <<< "$x_bar < $x_start + 1.5 - 0.5*$tcp_space") == 1 )) && \
210 (( $(bc <<< "$x_bar + $box_width > $x_start + 1.5 + 0.5*$tcp_space") \
211 == 1 )); then
212 x_bar=$(echo $x_bar + $tcp_space | bc)
213 fi
214
215 x_bar=$(echo $x_bar + $box_width | bc)
216
217 done
218 echo "e"
219
220 # Plot vertical error lines, e.g. y +- sigma.
221 data_sets=$(echo "$bars" | grep "ERRORBAR.$figure" | cut -f 3 | sort | uniq)
222
223 if (( ${#data_sets} > "0" )); then
224
225 echo "set key left"
226 error_title=$(echo "$bars" | grep "ERRORBAR.$figure" | cut -f 7 | \
227 head -n 1 | sed 's/_/ /g')
228
229 echo "set xtics $x_labels"
230 echo "plot '-' using 1:3:4:5 title '$error_title' with yerr"
231
232 x_error_line=$(echo $x_start + 0.5 + 0.5*$box_width | bc)
233 for set in $data_sets ; do
234 echo -n "$x_error_line "
235 echo "$bars" | grep "ERRORBAR.$figure.$set" | cut -f 3,4,5,6
236
237 # Add extra space if TCP flows are being plotted.
238 if $tcp_flow && \
239 (( $(bc <<< "$x_error_line < $x_start + 1.5 - 0.5*$tcp_space") == 1 \
240 )) && (( $(bc <<< "$x_error_line + $box_width > $x_start + 1.5 \
241 + 0.5*$tcp_space") == 1 )); then
242 x_error_line=$(echo $x_error_line + $tcp_space | bc)
243 fi
244
245 x_error_line=$(echo $x_error_line + $box_width | bc)
246 done
247 echo "e"
248 fi
249
250 # Plot horizontal dashed lines, e.g. y = optimal bitrate.
251 data_sets=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | cut -f 3 \
252 | sort | uniq)
253 if (( ${#data_sets} > "0" )); then
254
255 echo "set style line 1 lt 1 lw 3 pt 3 ps 0 linecolor rgb 'black'"
256
257 limit_titles=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | cut -f 9 \
258 | sort | uniq)
259
260 for title in $limit_titles ; do
261 y_max=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | grep "$title" \
262 | cut -f 8 | head -n 1)
263
264 retouched_title=$(echo "$title" | sed 's/#/\t/g' | cut -f 1 \
265 | sed 's/_/ /g')
266
267 echo "set key right top"
268 echo "set xtics $x_labels"
269 echo "plot $y_max lt 7 lw 1 linecolor rgb 'black' \
270 title '$retouched_title'"
271 done
272
273 fi
274
275 echo "unset multiplot"
276 done
277 }
278 gen_gnuplot_bar_input | gnuplot -persist
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698