Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: tools/perf/metrics/network.py

Issue 377333002: Update network to use results.AddValue(...) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.timeline import recording_options 16 from telemetry.timeline import recording_options
17 from telemetry.value import scalar
17 18
18 19
19 class NetworkMetricException(page_measurement.MeasurementFailure): 20 class NetworkMetricException(page_measurement.MeasurementFailure):
20 pass 21 pass
21 22
22 23
23 class HTTPResponse(object): 24 class HTTPResponse(object):
24 """ Represents an HTTP response from a timeline event.""" 25 """ Represents an HTTP response from a timeline event."""
25 def __init__(self, event): 26 def __init__(self, event):
26 self._response = ( 27 self._response = (
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 resource = resp.response.url 162 resource = resp.response.url
162 resource_signature = resp.url_signature 163 resource_signature = resp.url_signature
163 cl = resp.content_length 164 cl = resp.content_length
164 if resp.has_original_content_length: 165 if resp.has_original_content_length:
165 ocl = resp.original_content_length 166 ocl = resp.original_content_length
166 if ocl < cl: 167 if ocl < cl:
167 logging.warning('original content length (%d) is less than content ' 168 logging.warning('original content length (%d) is less than content '
168 'lenght(%d) for resource %s', ocl, cl, resource) 169 'lenght(%d) for resource %s', ocl, cl, resource)
169 if self.add_result_for_resource: 170 if self.add_result_for_resource:
170 results.Add('resource_data_saving_' + resource_signature, 171 results.AddValue(scalar.ScalarValue(
171 'percent', resp.data_saving_rate * 100) 172 results.current_page,
172 results.Add('resource_original_content_length_' + resource_signature, 173 'resource_data_saving_' + resource_signature, 'percent',
173 'bytes', ocl) 174 resp.data_saving_rate * 100))
175 results.AddValue(scalar.ScalarValue(
176 results.current_page,
177 'resource_original_content_length_' + resource_signature, 'bytes',
178 ocl))
174 original_content_length += ocl 179 original_content_length += ocl
175 else: 180 else:
176 original_content_length += cl 181 original_content_length += cl
177 if self.add_result_for_resource: 182 if self.add_result_for_resource:
178 results.Add( 183 results.Add(
179 'resource_content_length_' + resource_signature, 'bytes', cl) 184 'resource_content_length_' + resource_signature, 'bytes', cl)
180 content_length += cl 185 content_length += cl
181 186
182 results.Add('content_length', 'bytes', content_length) 187 results.AddValue(scalar.ScalarValue(
183 results.Add('original_content_length', 'bytes', original_content_length) 188 results.current_page, 'content_length', 'bytes', content_length))
189 results.AddValue(scalar.ScalarValue(
190 results.current_page, 'original_content_length', 'bytes',
191 original_content_length))
184 if self.compute_data_saving: 192 if self.compute_data_saving:
185 if (original_content_length > 0 and 193 if (original_content_length > 0 and
186 original_content_length >= content_length): 194 original_content_length >= content_length):
187 saving = (float(original_content_length-content_length) * 100 / 195 saving = (float(original_content_length-content_length) * 100 /
188 original_content_length) 196 original_content_length)
189 results.Add('data_saving', 'percent', saving) 197 results.AddValue(scalar.ScalarValue(
198 results.current_page, 'data_saving', 'percent', saving))
190 else: 199 else:
191 results.Add('data_saving', 'percent', 0.0) 200 results.AddValue(scalar.ScalarValue(
201 results.current_page, 'data_saving', 'percent', 0.0))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698