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 logging | 5 import logging |
6 import time | 6 import time |
7 | 7 |
8 from integration_tests import network_metrics | 8 from integration_tests import network_metrics |
9 from telemetry.page import page_test | 9 from telemetry.page import page_test |
10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 | 207 |
208 results.AddValue(scalar.ScalarValue( | 208 results.AddValue(scalar.ScalarValue( |
209 results.current_page, 'via', 'count', via_count)) | 209 results.current_page, 'via', 'count', via_count)) |
210 results.AddValue(scalar.ScalarValue( | 210 results.AddValue(scalar.ScalarValue( |
211 results.current_page, 'bypass', 'count', bypass_count)) | 211 results.current_page, 'bypass', 'count', bypass_count)) |
212 | 212 |
213 def AddResultsForLoFi(self, tab, results): | 213 def AddResultsForLoFi(self, tab, results): |
214 lo_fi_count = 0 | 214 lo_fi_count = 0 |
215 | 215 |
216 for resp in self.IterResponses(tab): | 216 for resp in self.IterResponses(tab): |
217 if resp.HasChromeProxyViaHeader(): | |
218 lo_fi_count += 1 | |
219 else: | |
220 r = resp.response | |
221 raise ChromeProxyMetricException, ( | |
222 '%s: LoFi not in request header.' % (r.url)) | |
223 | |
224 cl = resp.content_length | |
225 resource = resp.response.url | |
226 results.AddValue(scalar.ScalarValue( | |
227 results.current_page, 'lo_fi', 'count', lo_fi_count)) | |
228 | |
229 for resp in self.IterResponses(tab): | |
230 r = resp.response | 217 r = resp.response |
231 cl = resp.content_length | 218 cl = resp.content_length |
sclittle
2015/03/24 17:32:46
Just use resp.response.url and resp.content_length
megjablon
2015/03/24 18:05:18
Done.
| |
232 ocl = resp.original_content_length | 219 |
233 saving = resp.data_saving_rate * 100 | 220 if resp.HasChromeProxyLoFi(): |
221 lo_fi_count += 1 | |
222 else: | |
223 raise ChromeProxyMetricException, ( | |
224 '%s: LoFi not in request header.' % (r.url)) | |
225 | |
234 if cl > 100: | 226 if cl > 100: |
235 raise ChromeProxyMetricException, ( | 227 raise ChromeProxyMetricException, ( |
236 'Image %s is %d bytes. Expecting less than 100 bytes.' % | 228 'Image %s is %d bytes. Expecting less than 100 bytes.' % |
237 (resource, cl)) | 229 (r.url, cl)) |
230 | |
231 if lo_fi_count == 0: | |
232 raise ChromeProxyMetricException, ( | |
233 'Expected at least one LoFi response, but zero such responses were ' | |
234 'received.') | |
238 | 235 |
239 results.AddValue(scalar.ScalarValue( | 236 results.AddValue(scalar.ScalarValue( |
240 results.current_page, 'content_length', 'bytes', cl)) | 237 results.current_page, 'lo_fi', 'count', lo_fi_count)) |
241 results.AddValue(scalar.ScalarValue( | 238 super(ChromeProxyMetric, self).AddResults(tab, results) |
242 results.current_page, 'original_content_length', 'bytes', ocl)) | |
243 results.AddValue(scalar.ScalarValue( | |
244 results.current_page, 'data_saving', 'percent', saving)) | |
245 | 239 |
246 def AddResultsForBypass(self, tab, results): | 240 def AddResultsForBypass(self, tab, results): |
247 bypass_count = 0 | 241 bypass_count = 0 |
248 | 242 |
249 for resp in self.IterResponses(tab): | 243 for resp in self.IterResponses(tab): |
250 if resp.HasChromeProxyViaHeader(): | 244 if resp.HasChromeProxyViaHeader(): |
251 r = resp.response | 245 r = resp.response |
252 raise ChromeProxyMetricException, ( | 246 raise ChromeProxyMetricException, ( |
253 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( | 247 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( |
254 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) | 248 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 via_count += 1 | 486 via_count += 1 |
493 if via_count == 0: | 487 if via_count == 0: |
494 raise ChromeProxyMetricException, ( | 488 raise ChromeProxyMetricException, ( |
495 'Expected at least one response through the proxy after the bypass ' | 489 'Expected at least one response through the proxy after the bypass ' |
496 'expired, but zero such responses were received.') | 490 'expired, but zero such responses were received.') |
497 | 491 |
498 results.AddValue(scalar.ScalarValue( | 492 results.AddValue(scalar.ScalarValue( |
499 results.current_page, 'bypass', 'count', bypass_count)) | 493 results.current_page, 'bypass', 'count', bypass_count)) |
500 results.AddValue(scalar.ScalarValue( | 494 results.AddValue(scalar.ScalarValue( |
501 results.current_page, 'via', 'count', via_count)) | 495 results.current_page, 'via', 'count', via_count)) |
OLD | NEW |