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 zlib | 10 import zlib |
11 | 11 |
12 from metrics import Metric | 12 from metrics import Metric |
13 from telemetry.page import page_measurement | 13 from telemetry.page import page_measurement |
14 # All network metrics are Chrome only for now. | 14 # All network metrics are Chrome only for now. |
15 from telemetry.core.backends.chrome import inspector_network | 15 from telemetry.core.backends.chrome import inspector_network |
16 from telemetry.core.timeline import recording_options | 16 from telemetry.timeline import recording_options |
17 | 17 |
18 | 18 |
19 class NetworkMetricException(page_measurement.MeasurementFailure): | 19 class NetworkMetricException(page_measurement.MeasurementFailure): |
20 pass | 20 pass |
21 | 21 |
22 | 22 |
23 class HTTPResponse(object): | 23 class HTTPResponse(object): |
24 """ Represents an HTTP response from a timeline event.""" | 24 """ Represents an HTTP response from a timeline event.""" |
25 def __init__(self, event): | 25 def __init__(self, event): |
26 self._response = ( | 26 self._response = ( |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 results.Add('content_length', 'bytes', content_length) | 182 results.Add('content_length', 'bytes', content_length) |
183 results.Add('original_content_length', 'bytes', original_content_length) | 183 results.Add('original_content_length', 'bytes', original_content_length) |
184 if self.compute_data_saving: | 184 if self.compute_data_saving: |
185 if (original_content_length > 0 and | 185 if (original_content_length > 0 and |
186 original_content_length >= content_length): | 186 original_content_length >= content_length): |
187 saving = (float(original_content_length-content_length) * 100 / | 187 saving = (float(original_content_length-content_length) * 100 / |
188 original_content_length) | 188 original_content_length) |
189 results.Add('data_saving', 'percent', saving) | 189 results.Add('data_saving', 'percent', saving) |
190 else: | 190 else: |
191 results.Add('data_saving', 'percent', 0.0) | 191 results.Add('data_saving', 'percent', 0.0) |
OLD | NEW |