| 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 base64 | 5 import base64 |
| 6 import gzip | 6 import gzip |
| 7 import hashlib | 7 import hashlib |
| 8 import io | 8 import io |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| 11 import sys | 11 import sys |
| 12 import zlib | 12 import zlib |
| 13 | 13 |
| 14 from common import inspector_network | 14 from common import inspector_network |
| 15 from telemetry.timeline import model | 15 from telemetry.timeline import model |
| 16 | 16 |
| 17 sys.path.append( | 17 sys.path.append( |
| 18 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'perf')) | 18 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'perf')) |
| 19 from metrics import Metric | 19 from metrics import Metric |
| 20 | 20 |
| 21 from telemetry.page import page_test | 21 from telemetry.page import legacy_page_test |
| 22 # All network metrics are Chrome only for now. | 22 # All network metrics are Chrome only for now. |
| 23 from telemetry.value import scalar | 23 from telemetry.value import scalar |
| 24 | 24 |
| 25 | 25 |
| 26 class NetworkMetricException(page_test.MeasurementFailure): | 26 class NetworkMetricException(page_test.MeasurementFailure): |
| 27 pass | 27 pass |
| 28 | 28 |
| 29 | 29 |
| 30 class HTTPResponse(object): | 30 class HTTPResponse(object): |
| 31 """ Represents an HTTP response from a timeline event.""" | 31 """ Represents an HTTP response from a timeline event.""" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if self.compute_data_saving: | 210 if self.compute_data_saving: |
| 211 if (original_content_length > 0 and | 211 if (original_content_length > 0 and |
| 212 original_content_length >= content_length): | 212 original_content_length >= content_length): |
| 213 saving = (float(original_content_length-content_length) * 100 / | 213 saving = (float(original_content_length-content_length) * 100 / |
| 214 original_content_length) | 214 original_content_length) |
| 215 results.AddValue(scalar.ScalarValue( | 215 results.AddValue(scalar.ScalarValue( |
| 216 results.current_page, 'data_saving', 'percent', saving)) | 216 results.current_page, 'data_saving', 'percent', saving)) |
| 217 else: | 217 else: |
| 218 results.AddValue(scalar.ScalarValue( | 218 results.AddValue(scalar.ScalarValue( |
| 219 results.current_page, 'data_saving', 'percent', 0.0)) | 219 results.current_page, 'data_saving', 'percent', 0.0)) |
| OLD | NEW |