Chromium Code Reviews| 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(): | 217 if resp.HasChromeProxyLoFi(): |
| 218 lo_fi_count += 1 | 218 lo_fi_count += 1 |
| 219 else: | 219 else: |
| 220 r = resp.response | 220 r = resp.response |
| 221 raise ChromeProxyMetricException, ( | 221 raise ChromeProxyMetricException, ( |
| 222 '%s: LoFi not in request header.' % (r.url)) | 222 '%s: LoFi not in request header.' % (r.url)) |
| 223 | 223 |
| 224 cl = resp.content_length | 224 cl = resp.content_length |
|
sclittle
2015/03/24 01:27:38
Why write the "cl" variable here if it's overwritt
megjablon
2015/03/24 02:05:29
Done.
| |
| 225 resource = resp.response.url | 225 resource = resp.response.url |
|
sclittle
2015/03/24 01:27:38
Why is this variable set here? Is this variable ne
megjablon
2015/03/24 02:05:29
Done.
| |
| 226 results.AddValue(scalar.ScalarValue( | 226 results.AddValue(scalar.ScalarValue( |
|
sclittle
2015/03/24 01:27:38
While you're at it, could you also make it so that
megjablon
2015/03/24 02:05:29
Done.
| |
| 227 results.current_page, 'lo_fi', 'count', lo_fi_count)) | 227 results.current_page, 'lo_fi', 'count', lo_fi_count)) |
| 228 | 228 |
| 229 for resp in self.IterResponses(tab): | 229 for resp in self.IterResponses(tab): |
|
sclittle
2015/03/24 01:27:38
Could you combine these two for loops?
megjablon
2015/03/24 02:05:29
Done.
| |
| 230 r = resp.response | 230 r = resp.response |
|
sclittle
2015/03/24 01:27:38
unused variable
megjablon
2015/03/24 02:05:29
Done.
| |
| 231 cl = resp.content_length | 231 cl = resp.content_length |
| 232 ocl = resp.original_content_length | 232 ocl = resp.original_content_length |
| 233 saving = resp.data_saving_rate * 100 | 233 saving = resp.data_saving_rate * 100 |
| 234 if cl > 100: | 234 if cl > 100: |
| 235 raise ChromeProxyMetricException, ( | 235 raise ChromeProxyMetricException, ( |
| 236 'Image %s is %d bytes. Expecting less than 100 bytes.' % | 236 'Image %s is %d bytes. Expecting less than 100 bytes.' % |
| 237 (resource, cl)) | 237 (resource, cl)) |
| 238 | 238 |
| 239 results.AddValue(scalar.ScalarValue( | 239 results.AddValue(scalar.ScalarValue( |
|
sclittle
2015/03/24 01:27:38
Why report the last response's cl, ocl, and saving
megjablon
2015/03/24 02:05:29
Done.
| |
| 240 results.current_page, 'content_length', 'bytes', cl)) | 240 results.current_page, 'content_length', 'bytes', cl)) |
| 241 results.AddValue(scalar.ScalarValue( | 241 results.AddValue(scalar.ScalarValue( |
| 242 results.current_page, 'original_content_length', 'bytes', ocl)) | 242 results.current_page, 'original_content_length', 'bytes', ocl)) |
| 243 results.AddValue(scalar.ScalarValue( | 243 results.AddValue(scalar.ScalarValue( |
| 244 results.current_page, 'data_saving', 'percent', saving)) | 244 results.current_page, 'data_saving', 'percent', saving)) |
| 245 | 245 |
| 246 def AddResultsForBypass(self, tab, results): | 246 def AddResultsForBypass(self, tab, results): |
| 247 bypass_count = 0 | 247 bypass_count = 0 |
| 248 | 248 |
| 249 for resp in self.IterResponses(tab): | 249 for resp in self.IterResponses(tab): |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 via_count += 1 | 492 via_count += 1 |
| 493 if via_count == 0: | 493 if via_count == 0: |
| 494 raise ChromeProxyMetricException, ( | 494 raise ChromeProxyMetricException, ( |
| 495 'Expected at least one response through the proxy after the bypass ' | 495 'Expected at least one response through the proxy after the bypass ' |
| 496 'expired, but zero such responses were received.') | 496 'expired, but zero such responses were received.') |
| 497 | 497 |
| 498 results.AddValue(scalar.ScalarValue( | 498 results.AddValue(scalar.ScalarValue( |
| 499 results.current_page, 'bypass', 'count', bypass_count)) | 499 results.current_page, 'bypass', 'count', bypass_count)) |
| 500 results.AddValue(scalar.ScalarValue( | 500 results.AddValue(scalar.ScalarValue( |
| 501 results.current_page, 'via', 'count', via_count)) | 501 results.current_page, 'via', 'count', via_count)) |
| OLD | NEW |