| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Pull a sandwich run's output directory's metrics from traces into a CSV. | 5 """Pull a sandwich run's output directory's metrics from traces into a CSV. |
| 6 | 6 |
| 7 python pull_sandwich_metrics.py -h | 7 python pull_sandwich_metrics.py -h |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import collections | 10 import collections |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if event.category != 'blink.user_timing': | 128 if event.category != 'blink.user_timing': |
| 129 continue | 129 continue |
| 130 event_name = event.name | 130 event_name = event.name |
| 131 | 131 |
| 132 # Find the id of the main frame. Skip all events until it is found. | 132 # Find the id of the main frame. Skip all events until it is found. |
| 133 if not main_frame_id: | 133 if not main_frame_id: |
| 134 # Tracing (in Sandwich) is started after about:blank is fully loaded, | 134 # Tracing (in Sandwich) is started after about:blank is fully loaded, |
| 135 # hence the first navigationStart in the trace registers the correct frame | 135 # hence the first navigationStart in the trace registers the correct frame |
| 136 # id. | 136 # id. |
| 137 if event_name == 'navigationStart': | 137 if event_name == 'navigationStart': |
| 138 logging.info('Found navigationStart at: %f', event.start_msec) | 138 logging.info(' Found navigationStart at: %f', event.start_msec) |
| 139 main_frame_id = event.args['frame'] | 139 main_frame_id = event.args['frame'] |
| 140 continue | 140 continue |
| 141 | 141 |
| 142 # Ignore events with frame id attached, but not being the main frame. | 142 # Ignore events with frame id attached, but not being the main frame. |
| 143 if 'frame' in event.args and event.args['frame'] != main_frame_id: | 143 if 'frame' in event.args and event.args['frame'] != main_frame_id: |
| 144 continue | 144 continue |
| 145 | 145 |
| 146 # Capture trace events by the first time of their appearance. Note: some | 146 # Capture trace events by the first time of their appearance. Note: some |
| 147 # important events (like requestStart) do not have a frame id attached. | 147 # important events (like requestStart) do not have a frame id attached. |
| 148 if event_name in _TRACKED_EVENT_NAMES and event_name not in tracked_events: | 148 if event_name in _TRACKED_EVENT_NAMES and event_name not in tracked_events: |
| 149 tracked_events[event_name] = event | 149 tracked_events[event_name] = event |
| 150 logging.info('Event %s first appears at: %f', event_name, | 150 logging.info(' Event %s first appears at: %f', event_name, |
| 151 event.start_msec) | 151 event.start_msec) |
| 152 return tracked_events | 152 return tracked_events |
| 153 | 153 |
| 154 | 154 |
| 155 def _ExtractDefaultMetrics(loading_trace): | 155 def _ExtractDefaultMetrics(loading_trace): |
| 156 """Extracts all the default metrics from a given trace. | 156 """Extracts all the default metrics from a given trace. |
| 157 | 157 |
| 158 Args: | 158 Args: |
| 159 loading_trace: loading_trace.LoadingTrace. | 159 loading_trace: loading_trace.LoadingTrace. |
| 160 | 160 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 except video.BoundingBoxNotFoundException: | 301 except video.BoundingBoxNotFoundException: |
| 302 # Sometimes the bounding box for the web content area is not present. Skip | 302 # Sometimes the bounding box for the web content area is not present. Skip |
| 303 # calculating Speed Index. | 303 # calculating Speed Index. |
| 304 run_metrics['speed_index'] = _FAILED_CSV_VALUE | 304 run_metrics['speed_index'] = _FAILED_CSV_VALUE |
| 305 else: | 305 else: |
| 306 run_metrics['speed_index'] = _UNAVAILABLE_CSV_VALUE | 306 run_metrics['speed_index'] = _UNAVAILABLE_CSV_VALUE |
| 307 for key, value in trace.metadata['network_emulation'].iteritems(): | 307 for key, value in trace.metadata['network_emulation'].iteritems(): |
| 308 run_metrics['net_emul.' + key] = value | 308 run_metrics['net_emul.' + key] = value |
| 309 assert set(run_metrics.keys()) == set(COMMON_CSV_COLUMN_NAMES) | 309 assert set(run_metrics.keys()) == set(COMMON_CSV_COLUMN_NAMES) |
| 310 return run_metrics | 310 return run_metrics |
| OLD | NEW |