| OLD | NEW |
| 1 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 1 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 2 # | 2 # |
| 3 # Use of this source code is governed by a BSD-style license | 3 # Use of this source code is governed by a BSD-style license |
| 4 # that can be found in the LICENSE file in the root of the source | 4 # that can be found in the LICENSE file in the root of the source |
| 5 # tree. An additional intellectual property rights grant can be found | 5 # tree. An additional intellectual property rights grant can be found |
| 6 # in the file PATENTS. All contributing project authors may | 6 # in the file PATENTS. All contributing project authors may |
| 7 # be found in the AUTHORS file in the root of the source tree. | 7 # be found in the AUTHORS file in the root of the source tree. |
| 8 | 8 |
| 9 """Plots statistics from WebRTC integration test logs. | 9 """Plots statistics from WebRTC integration test logs. |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 Args: | 110 Args: |
| 111 filename: The name of the file. | 111 filename: The name of the file. |
| 112 setting: Name of setting to parse (e.g. width). | 112 setting: Name of setting to parse (e.g. width). |
| 113 | 113 |
| 114 Returns: | 114 Returns: |
| 115 A list holding parsed settings, e.g. ['width: 128.0', 'width: 160.0'] """ | 115 A list holding parsed settings, e.g. ['width: 128.0', 'width: 160.0'] """ |
| 116 | 116 |
| 117 settings = [] | 117 settings = [] |
| 118 | 118 |
| 119 f = open(filename) | 119 settings_file = open(filename) |
| 120 while True: | 120 while True: |
| 121 line = f.readline() | 121 line = settings_file.readline() |
| 122 if not line: | 122 if not line: |
| 123 break | 123 break |
| 124 if re.search(r'%s' % EVENT_START, line): | 124 if re.search(r'%s' % EVENT_START, line): |
| 125 # Parse event. | 125 # Parse event. |
| 126 parsed = {} | 126 parsed = {} |
| 127 while True: | 127 while True: |
| 128 line = f.readline() | 128 line = settings_file.readline() |
| 129 if not line: | 129 if not line: |
| 130 break | 130 break |
| 131 if re.search(r'%s' % EVENT_END, line): | 131 if re.search(r'%s' % EVENT_END, line): |
| 132 # Add parsed setting to list. | 132 # Add parsed setting to list. |
| 133 if setting in parsed: | 133 if setting in parsed: |
| 134 s = setting + ': ' + str(parsed[setting]) | 134 s = setting + ': ' + str(parsed[setting]) |
| 135 if s not in settings: | 135 if s not in settings: |
| 136 settings.append(s) | 136 settings.append(s) |
| 137 break | 137 break |
| 138 | 138 |
| 139 TryFindMetric(parsed, line, f) | 139 TryFindMetric(parsed, line, settings_file) |
| 140 | 140 |
| 141 f.close() | 141 settings_file.close() |
| 142 return settings | 142 return settings |
| 143 | 143 |
| 144 | 144 |
| 145 def ParseMetrics(filename, setting1, setting2): | 145 def ParseMetrics(filename, setting1, setting2): |
| 146 """Parses metrics from file. | 146 """Parses metrics from file. |
| 147 | 147 |
| 148 Args: | 148 Args: |
| 149 filename: The name of the file. | 149 filename: The name of the file. |
| 150 setting1: First setting for sorting metrics (e.g. width). | 150 setting1: First setting for sorting metrics (e.g. width). |
| 151 setting2: Second setting for sorting metrics (e.g. CPU cores used). | 151 setting2: Second setting for sorting metrics (e.g. CPU cores used). |
| (...skipping 22 matching lines...) Expand all Loading... |
| 174 "encode time (us)": [0.857897, 0.91608, 0.959173, 0.971116, 0.980961], | 174 "encode time (us)": [0.857897, 0.91608, 0.959173, 0.971116, 0.980961], |
| 175 "PSNR (dB)": [30.243646, 33.375592, 37.574387, 39.42184, 41.437897], | 175 "PSNR (dB)": [30.243646, 33.375592, 37.574387, 39.42184, 41.437897], |
| 176 "bitrate (kbps)": [50, 100, 300, 500, 1000] | 176 "bitrate (kbps)": [50, 100, 300, 500, 1000] |
| 177 }, | 177 }, |
| 178 } | 178 } |
| 179 } """ | 179 } """ |
| 180 | 180 |
| 181 metrics = {} | 181 metrics = {} |
| 182 | 182 |
| 183 # Parse events. | 183 # Parse events. |
| 184 f = open(filename) | 184 settings_file = open(filename) |
| 185 while True: | 185 while True: |
| 186 line = f.readline() | 186 line = settings_file.readline() |
| 187 if not line: | 187 if not line: |
| 188 break | 188 break |
| 189 if re.search(r'%s' % EVENT_START, line): | 189 if re.search(r'%s' % EVENT_START, line): |
| 190 # Parse event. | 190 # Parse event. |
| 191 parsed = {} | 191 parsed = {} |
| 192 while True: | 192 while True: |
| 193 line = f.readline() | 193 line = settings_file.readline() |
| 194 if not line: | 194 if not line: |
| 195 break | 195 break |
| 196 if re.search(r'%s' % EVENT_END, line): | 196 if re.search(r'%s' % EVENT_END, line): |
| 197 # Add parsed values to metrics. | 197 # Add parsed values to metrics. |
| 198 key1 = setting1 + ': ' + str(parsed[setting1]) | 198 key1 = setting1 + ': ' + str(parsed[setting1]) |
| 199 key2 = setting2 + ': ' + str(parsed[setting2]) | 199 key2 = setting2 + ': ' + str(parsed[setting2]) |
| 200 if key1 not in metrics: | 200 if key1 not in metrics: |
| 201 metrics[key1] = {} | 201 metrics[key1] = {} |
| 202 if key2 not in metrics[key1]: | 202 if key2 not in metrics[key1]: |
| 203 metrics[key1][key2] = {} | 203 metrics[key1][key2] = {} |
| 204 | 204 |
| 205 for label in parsed: | 205 for label in parsed: |
| 206 if label not in metrics[key1][key2]: | 206 if label not in metrics[key1][key2]: |
| 207 metrics[key1][key2][label] = [] | 207 metrics[key1][key2][label] = [] |
| 208 metrics[key1][key2][label].append(parsed[label]) | 208 metrics[key1][key2][label].append(parsed[label]) |
| 209 | 209 |
| 210 break | 210 break |
| 211 | 211 |
| 212 TryFindMetric(parsed, line, f) | 212 TryFindMetric(parsed, line, settings_file) |
| 213 | 213 |
| 214 f.close() | 214 settings_file.close() |
| 215 return metrics | 215 return metrics |
| 216 | 216 |
| 217 | 217 |
| 218 def TryFindMetric(parsed, line, f): | 218 def TryFindMetric(parsed, line, settings_file): |
| 219 for metric in METRICS_TO_PARSE: | 219 for metric in METRICS_TO_PARSE: |
| 220 name = metric[0] | 220 name = metric[0] |
| 221 label = metric[1] | 221 label = metric[1] |
| 222 if re.search(r'%s' % name, line): | 222 if re.search(r'%s' % name, line): |
| 223 found, value = GetMetric(name, line) | 223 found, value = GetMetric(name, line) |
| 224 if not found: | 224 if not found: |
| 225 # TODO(asapersson): Change format. | 225 # TODO(asapersson): Change format. |
| 226 # Try find min, max, average stats. | 226 # Try find min, max, average stats. |
| 227 found, minimum = GetMetric("Min", f.readline()) | 227 found, minimum = GetMetric("Min", settings_file.readline()) |
| 228 if not found: | 228 if not found: |
| 229 return | 229 return |
| 230 found, maximum = GetMetric("Max", f.readline()) | 230 found, maximum = GetMetric("Max", settings_file.readline()) |
| 231 if not found: | 231 if not found: |
| 232 return | 232 return |
| 233 found, average = GetMetric("Average", f.readline()) | 233 found, average = GetMetric("Average", settings_file.readline()) |
| 234 if not found: | 234 if not found: |
| 235 return | 235 return |
| 236 | 236 |
| 237 parsed[label + ' min'] = minimum | 237 parsed[label + ' min'] = minimum |
| 238 parsed[label + ' max'] = maximum | 238 parsed[label + ' max'] = maximum |
| 239 parsed[label + ' avg'] = average | 239 parsed[label + ' avg'] = average |
| 240 | 240 |
| 241 parsed[label] = value | 241 parsed[label] = value |
| 242 return | 242 return |
| 243 | 243 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 figsize[1] *= FIG_SIZE_SCALE_FACTOR_Y | 430 figsize[1] *= FIG_SIZE_SCALE_FACTOR_Y |
| 431 plt.rcParams["figure.figsize"] = figsize | 431 plt.rcParams["figure.figsize"] = figsize |
| 432 | 432 |
| 433 PlotFigure(sub_keys, y_metrics, x_metric, metrics, GetTitle(filename)) | 433 PlotFigure(sub_keys, y_metrics, x_metric, metrics, GetTitle(filename)) |
| 434 | 434 |
| 435 plt.show() | 435 plt.show() |
| 436 | 436 |
| 437 | 437 |
| 438 if __name__ == '__main__': | 438 if __name__ == '__main__': |
| 439 main() | 439 main() |
| OLD | NEW |