OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import json | 5 import json |
6 import logging | 6 import logging |
7 import re | 7 import re |
8 | 8 |
9 from telemetry.internal.util import camel_case | 9 from telemetry.internal.util import camel_case |
10 from telemetry.value import list_of_scalar_values | 10 from telemetry.value import list_of_scalar_values |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 def __init__(self, particular_metrics=None): | 133 def __init__(self, particular_metrics=None): |
134 super(WebRtcStatisticsMetric, self).__init__() | 134 super(WebRtcStatisticsMetric, self).__init__() |
135 self._all_reports = None | 135 self._all_reports = None |
136 self._selected_metrics = SelectMetrics(particular_metrics) | 136 self._selected_metrics = SelectMetrics(particular_metrics) |
137 | 137 |
138 def Start(self, page, tab): | 138 def Start(self, page, tab): |
139 pass | 139 pass |
140 | 140 |
141 def Stop(self, page, tab): | 141 def Stop(self, page, tab): |
142 """Digs out stats from data populated by the javascript in webrtc_cases.""" | 142 """Digs out stats from data populated by the javascript in webrtc_cases.""" |
143 self._all_reports = tab.EvaluateJavaScript2( | 143 self._all_reports = tab.EvaluateJavaScript( |
144 'JSON.stringify(window.peerConnectionReports)') | 144 'JSON.stringify(window.peerConnectionReports)') |
145 | 145 |
146 def AddResults(self, tab, results): | 146 def AddResults(self, tab, results): |
147 if not self._all_reports: | 147 if not self._all_reports: |
148 return | 148 return |
149 | 149 |
150 reports = json.loads(self._all_reports) | 150 reports = json.loads(self._all_reports) |
151 for i, report in enumerate(reports): | 151 for i, report in enumerate(reports): |
152 time_series = SortStatsIntoTimeSeries(report, self._selected_metrics) | 152 time_series = SortStatsIntoTimeSeries(report, self._selected_metrics) |
153 | 153 |
154 # Only ever show stats for 5 peer connections, or it's going to look | 154 # Only ever show stats for 5 peer connections, or it's going to look |
155 # insane in the results. | 155 # insane in the results. |
156 if i > 5: | 156 if i > 5: |
157 PrintSpecialMarkerValue(results) | 157 PrintSpecialMarkerValue(results) |
158 return | 158 return |
159 | 159 |
160 for stat_name, values in time_series.iteritems(): | 160 for stat_name, values in time_series.iteritems(): |
161 stat_name_underscored = camel_case.ToUnderscore(stat_name) | 161 stat_name_underscored = camel_case.ToUnderscore(stat_name) |
162 trace_name = 'peer_connection_%d_%s' % (i, stat_name_underscored) | 162 trace_name = 'peer_connection_%d_%s' % (i, stat_name_underscored) |
163 general_name = StripAudioVideoBweDistinction(stat_name) | 163 general_name = StripAudioVideoBweDistinction(stat_name) |
164 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 164 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
165 results.current_page, trace_name, | 165 results.current_page, trace_name, |
166 INTERESTING_METRICS[general_name]['units'], values, | 166 INTERESTING_METRICS[general_name]['units'], values, |
167 description=INTERESTING_METRICS[general_name]['description'], | 167 description=INTERESTING_METRICS[general_name]['description'], |
168 important=False)) | 168 important=False)) |
OLD | NEW |