| 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 """Generate graphs for data generated by full_stack_quality_sampler.cc. | 10 """Generate graphs for data generated by loopback tests. |
| 11 | 11 |
| 12 Usage examples: | 12 Usage examples: |
| 13 Show end to end time for a single full stack test. | 13 Show end to end time for a single full stack test. |
| 14 ./full_stack_plot.py -df end_to_end -o 600 --frames 1000 vp9_data.txt | 14 ./full_stack_plot.py -df end_to_end -o 600 --frames 1000 vp9_data.txt |
| 15 | 15 |
| 16 Show simultaneously PSNR and encoded frame size for two different runs of | 16 Show simultaneously PSNR and encoded frame size for two different runs of |
| 17 full stack test. Averaged over a cycle of 200 frames. Used e.g. for | 17 full stack test. Averaged over a cycle of 200 frames. Used e.g. for |
| 18 screenshare slide test. | 18 screenshare slide test. |
| 19 ./full_stack_plot.py -c 200 -df psnr -drf encoded_frame_size \\ | 19 ./full_stack_plot.py -c 200 -df psnr -drf encoded_frame_size \\ |
| 20 before.txt after.txt | 20 before.txt after.txt |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 # Auto-generated | 69 # Auto-generated |
| 70 (SENDER_TIME, "sender_time", "sender time"), | 70 (SENDER_TIME, "sender_time", "sender time"), |
| 71 (RECEIVER_TIME, "receiver_time", "receiver time"), | 71 (RECEIVER_TIME, "receiver_time", "receiver time"), |
| 72 (END_TO_END, "end_to_end", "end to end"), | 72 (END_TO_END, "end_to_end", "end to end"), |
| 73 (RENDERED_DELTA, "rendered_delta", "rendered delta"), | 73 (RENDERED_DELTA, "rendered_delta", "rendered delta"), |
| 74 ] | 74 ] |
| 75 | 75 |
| 76 name_to_id = {field[1]: field[0] for field in _fields} | 76 name_to_id = {field[1]: field[0] for field in _fields} |
| 77 id_to_title = {field[0]: field[2] for field in _fields} | 77 id_to_title = {field[0]: field[2] for field in _fields} |
| 78 | 78 |
| 79 | |
| 80 def field_arg_to_id(arg): | 79 def field_arg_to_id(arg): |
| 81 if arg == "none": | 80 if arg == "none": |
| 82 return None | 81 return None |
| 83 if arg in name_to_id: | 82 if arg in name_to_id: |
| 84 return name_to_id[arg] | 83 return name_to_id[arg] |
| 85 if arg + "_ms" in name_to_id: | 84 if arg + "_ms" in name_to_id: |
| 86 return name_to_id[arg + "_ms"] | 85 return name_to_id[arg + "_ms"] |
| 87 raise Exception("Unrecognized field name \"{}\"".format(arg)) | 86 raise Exception("Unrecognized field name \"{}\"".format(arg)) |
| 88 | 87 |
| 89 | 88 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 else: | 289 else: |
| 291 data = Data(filename) | 290 data = Data(filename) |
| 292 load_files.cache[filename] = data | 291 load_files.cache[filename] = data |
| 293 result.append(data) | 292 result.append(data) |
| 294 return result | 293 return result |
| 295 load_files.cache = {} | 294 load_files.cache = {} |
| 296 | 295 |
| 297 | 296 |
| 298 def get_parser(): | 297 def get_parser(): |
| 299 class CustomAction(argparse.Action): | 298 class CustomAction(argparse.Action): |
| 300 | |
| 301 def __call__(self, parser, namespace, values, option_string=None): | 299 def __call__(self, parser, namespace, values, option_string=None): |
| 302 if "ordered_args" not in namespace: | 300 if "ordered_args" not in namespace: |
| 303 namespace.ordered_args = [] | 301 namespace.ordered_args = [] |
| 304 namespace.ordered_args.append((self.dest, values)) | 302 namespace.ordered_args.append((self.dest, values)) |
| 305 | 303 |
| 306 parser = argparse.ArgumentParser( | 304 parser = argparse.ArgumentParser( |
| 307 description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | 305 description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) |
| 308 | 306 |
| 309 parser.add_argument( | 307 parser.add_argument( |
| 310 "-c", "--cycle_length", nargs=1, action=CustomAction, | 308 "-c", "--cycle_length", nargs=1, action=CustomAction, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 324 "--frames", nargs=1, action=CustomAction, type=int, | 322 "--frames", nargs=1, action=CustomAction, type=int, |
| 325 help="Frame count to show or take into account while averaging.") | 323 help="Frame count to show or take into account while averaging.") |
| 326 parser.add_argument("-t", "--title", nargs=1, action=CustomAction, | 324 parser.add_argument("-t", "--title", nargs=1, action=CustomAction, |
| 327 help="Title of the graph.") | 325 help="Title of the graph.") |
| 328 parser.add_argument( | 326 parser.add_argument( |
| 329 "-O", "--output_filename", nargs=1, action=CustomAction, | 327 "-O", "--output_filename", nargs=1, action=CustomAction, |
| 330 help="Use to save the graph into a file. " | 328 help="Use to save the graph into a file. " |
| 331 "Otherwise, a window will be shown.") | 329 "Otherwise, a window will be shown.") |
| 332 parser.add_argument( | 330 parser.add_argument( |
| 333 "files", nargs="+", action=CustomAction, | 331 "files", nargs="+", action=CustomAction, |
| 334 help="List of text-based files generated by full_stack.cc") | 332 help="List of text-based files generated by loopback tests.") |
| 335 return parser | 333 return parser |
| 336 | 334 |
| 337 | 335 |
| 338 def _plot_config_from_args(args, graph_num): | 336 def _plot_config_from_args(args, graph_num): |
| 339 # Pylint complains about using kwargs, so have to do it this way. | 337 # Pylint complains about using kwargs, so have to do it this way. |
| 340 cycle_length = None | 338 cycle_length = None |
| 341 frames = None | 339 frames = None |
| 342 offset = 0 | 340 offset = 0 |
| 343 output_filename = None | 341 output_filename = None |
| 344 title = "Graph" | 342 title = "Graph" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 config.plot(ax) | 403 config.plot(ax) |
| 406 if config.output_filename: | 404 if config.output_filename: |
| 407 print "Saving to", config.output_filename | 405 print "Saving to", config.output_filename |
| 408 fig.savefig(config.output_filename) | 406 fig.savefig(config.output_filename) |
| 409 plt.close(fig) | 407 plt.close(fig) |
| 410 | 408 |
| 411 plt.show() | 409 plt.show() |
| 412 | 410 |
| 413 if __name__ == "__main__": | 411 if __name__ == "__main__": |
| 414 show_or_save_plots(plot_configs_from_args(sys.argv[1:])) | 412 show_or_save_plots(plot_configs_from_args(sys.argv[1:])) |
| OLD | NEW |