OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 # | 3 # |
4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
9 | 9 |
10 # This script is used to plot simulation dynamics. The expected format is | 10 # This script is used to plot simulation dynamics. The expected format is |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 def AddSample(self, var_name, ssrc, alg_name, time, value): | 71 def AddSample(self, var_name, ssrc, alg_name, time, value): |
72 for s in self.subplots: | 72 for s in self.subplots: |
73 s.AddSample(var_name, ssrc, alg_name, time, value) | 73 s.AddSample(var_name, ssrc, alg_name, time, value) |
74 | 74 |
75 def PlotFigure(self, fig): | 75 def PlotFigure(self, fig): |
76 n = len(self.subplots) | 76 n = len(self.subplots) |
77 for i in range(n): | 77 for i in range(n): |
78 axis = fig.add_subplot(n, 1, i+1) | 78 axis = fig.add_subplot(n, 1, i+1) |
79 self.subplots[i].PlotSubplot(axis) | 79 self.subplots[i].PlotSubplot(axis) |
80 | 80 |
81 | |
82 class Subplot(object): | 81 class Subplot(object): |
83 def __init__(self, var_names, xlabel, ylabel): | 82 def __init__(self, var_names, xlabel, ylabel): |
84 self.xlabel = xlabel | 83 self.xlabel = xlabel |
85 self.ylabel = ylabel | 84 self.ylabel = ylabel |
86 self.var_names = var_names | 85 self.var_names = var_names |
87 self.samples = dict() | 86 self.samples = dict() |
88 | 87 |
89 def AddSample(self, var_name, ssrc, alg_name, time, value): | 88 def AddSample(self, var_name, ssrc, alg_name, time, value): |
90 if var_name not in self.var_names: | 89 if var_name not in self.var_names: |
91 return | 90 return |
(...skipping 12 matching lines...) Expand all Loading... |
104 axis.set_ylabel(self.ylabel) | 103 axis.set_ylabel(self.ylabel) |
105 | 104 |
106 count = 0 | 105 count = 0 |
107 for alg_name in self.samples.keys(): | 106 for alg_name in self.samples.keys(): |
108 for ssrc in self.samples[alg_name].keys(): | 107 for ssrc in self.samples[alg_name].keys(): |
109 for var_name in self.samples[alg_name][ssrc].keys(): | 108 for var_name in self.samples[alg_name][ssrc].keys(): |
110 x = [sample[0] for sample in self.samples[alg_name][ssrc][var_name]] | 109 x = [sample[0] for sample in self.samples[alg_name][ssrc][var_name]] |
111 y = [sample[1] for sample in self.samples[alg_name][ssrc][var_name]] | 110 y = [sample[1] for sample in self.samples[alg_name][ssrc][var_name]] |
112 x = numpy.array(x) | 111 x = numpy.array(x) |
113 y = numpy.array(y) | 112 y = numpy.array(y) |
114 | |
115 ssrc_count = len(self.samples[alg_name].keys()) | 113 ssrc_count = len(self.samples[alg_name].keys()) |
116 l = GenerateLabel(var_name, ssrc, ssrc_count, alg_name) | 114 l = GenerateLabel(var_name, ssrc, ssrc_count, alg_name) |
117 plt.plot(x, y, label=l, linewidth=2.0) | 115 if l == 'MaxThroughput_': |
| 116 plt.plot(x, y, label=l, linewidth=4.0) |
| 117 else: |
| 118 plt.plot(x, y, label=l, linewidth=2.0) |
118 count += 1 | 119 count += 1 |
119 | 120 |
120 plt.grid(True) | 121 plt.grid(True) |
121 if count > 1: | 122 if count > 1: |
122 plt.legend(loc='best') | 123 plt.legend(loc='best') |
123 | 124 |
124 | 125 |
125 def main(): | 126 def main(): |
126 receiver = Figure("PacketReceiver") | 127 receiver = Figure("PacketReceiver") |
127 receiver.AddSubplot(['Throughput_kbps', 'MaxThroughput_', 'Capacity_kbps', | 128 receiver.AddSubplot(['Throughput_kbps', 'MaxThroughput_', 'Capacity_kbps', |
(...skipping 13 matching lines...) Expand all Loading... |
141 | 142 |
142 trendline_state = Figure("TrendlineState") | 143 trendline_state = Figure("TrendlineState") |
143 trendline_state.AddSubplot(["accumulated_delay_ms", "smoothed_delay_ms"], | 144 trendline_state.AddSubplot(["accumulated_delay_ms", "smoothed_delay_ms"], |
144 "Time (s)", "Delay (ms)") | 145 "Time (s)", "Delay (ms)") |
145 trendline_state.AddSubplot(["trendline_slope"], "Time (s)", "Slope") | 146 trendline_state.AddSubplot(["trendline_slope"], "Time (s)", "Slope") |
146 | 147 |
147 target_bitrate = Figure("TargetBitrate") | 148 target_bitrate = Figure("TargetBitrate") |
148 target_bitrate.AddSubplot(['target_bitrate_bps', 'acknowledged_bitrate'], | 149 target_bitrate.AddSubplot(['target_bitrate_bps', 'acknowledged_bitrate'], |
149 "Time (s)", "Bitrate (bps)") | 150 "Time (s)", "Bitrate (bps)") |
150 | 151 |
| 152 min_rtt_state = Figure("MinRttState") |
| 153 min_rtt_state.AddSubplot(['MinRtt'], "Time (s)", "Time (ms)") |
| 154 |
151 # Select which figures to plot here. | 155 # Select which figures to plot here. |
152 figures = [receiver, detector_state, trendline_state, target_bitrate] | 156 figures = [receiver, detector_state, trendline_state, target_bitrate, |
| 157 min_rtt_state] |
153 | 158 |
154 # Add samples to the figures. | 159 # Add samples to the figures. |
155 for line in sys.stdin: | 160 for line in sys.stdin: |
156 if line.startswith("[ RUN ]"): | 161 if line.startswith("[ RUN ]"): |
157 test_name = re.search(r'\.(\w+)', line).group(1) | 162 test_name = re.search(r'\.(\w+)', line).group(1) |
158 if line.startswith("PLOT"): | 163 if line.startswith("PLOT"): |
159 try: | 164 try: |
160 (var_name, ssrc, alg_name, time, value) = ParsePlotLine(line) | 165 (var_name, ssrc, alg_name, time, value) = ParsePlotLine(line) |
161 for f in figures: | 166 for f in figures: |
162 # The sample will be ignored bv the figures that don't need it. | 167 # The sample will be ignored bv the figures that don't need it. |
163 f.AddSample(var_name, ssrc, alg_name, time, value) | 168 f.AddSample(var_name, ssrc, alg_name, time, value) |
164 except ParsePlotLineException as e: | 169 except ParsePlotLineException as e: |
165 print e.reason | 170 print e.reason |
166 print e.line | 171 print e.line |
167 | 172 |
168 # Plot figures. | 173 # Plot figures. |
169 for f in figures: | 174 for f in figures: |
170 fig = plt.figure(f.name) | 175 fig = plt.figure(f.name) |
171 f.PlotFigure(fig) | 176 f.PlotFigure(fig) |
172 if SAVE_FIGURE: | 177 if SAVE_FIGURE: |
173 fig.savefig(test_name + f.name + ".png") | 178 fig.savefig(test_name + f.name + ".png") |
174 plt.show() | 179 plt.show() |
175 | 180 |
176 if __name__ == '__main__': | 181 if __name__ == '__main__': |
177 main() | 182 main() |
OLD | NEW |