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

Side by Side Diff: tools/chrome_proxy/integration_tests/network_metrics.py

Issue 903523002: Revert of Remove usages of Timeline commands in telemetry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_backend.py » ('j') | 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_test 13 from telemetry.page import page_test
14 # All network metrics are Chrome only for now. 14 # All network metrics are Chrome only for now.
15 from telemetry.core.backends.chrome_inspector import inspector_network 15 from telemetry.core.backends.chrome_inspector import inspector_network
16 from telemetry.timeline import recording_options
16 from telemetry.value import scalar 17 from telemetry.value import scalar
17 18
18 19
19 class NetworkMetricException(page_test.MeasurementFailure): 20 class NetworkMetricException(page_test.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):
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 def __init__(self): 131 def __init__(self):
131 super(NetworkMetric, self).__init__() 132 super(NetworkMetric, self).__init__()
132 133
133 # Whether to add detailed result for each sub-resource in a page. 134 # Whether to add detailed result for each sub-resource in a page.
134 self.add_result_for_resource = False 135 self.add_result_for_resource = False
135 self.compute_data_saving = False 136 self.compute_data_saving = False
136 self._events = None 137 self._events = None
137 138
138 def Start(self, page, tab): 139 def Start(self, page, tab):
139 self._events = None 140 self._events = None
140 tab.StartTimelineRecording() 141 opts = recording_options.TimelineRecordingOptions()
142 opts.record_network = True
143 tab.StartTimelineRecording(opts)
141 144
142 def Stop(self, page, tab): 145 def Stop(self, page, tab):
143 assert self._events is None 146 assert self._events is None
144 tab.StopTimelineRecording() 147 tab.StopTimelineRecording()
145 148
146 def IterResponses(self, tab): 149 def IterResponses(self, tab):
147 if self._events is None: 150 if self._events is None:
148 self._events = tab.timeline_model.GetAllEventsOfName('HTTPResponse') 151 self._events = tab.timeline_model.GetAllEventsOfName('HTTPResponse')
149 if len(self._events) == 0: 152 if len(self._events) == 0:
150 return 153 return
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if self.compute_data_saving: 200 if self.compute_data_saving:
198 if (original_content_length > 0 and 201 if (original_content_length > 0 and
199 original_content_length >= content_length): 202 original_content_length >= content_length):
200 saving = (float(original_content_length-content_length) * 100 / 203 saving = (float(original_content_length-content_length) * 100 /
201 original_content_length) 204 original_content_length)
202 results.AddValue(scalar.ScalarValue( 205 results.AddValue(scalar.ScalarValue(
203 results.current_page, 'data_saving', 'percent', saving)) 206 results.current_page, 'data_saving', 'percent', saving))
204 else: 207 else:
205 results.AddValue(scalar.ScalarValue( 208 results.AddValue(scalar.ScalarValue(
206 results.current_page, 'data_saving', 'percent', 0.0)) 209 results.current_page, 'data_saving', 'percent', 0.0))
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698