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

Side by Side Diff: tools/perf/benchmarks/service_worker.py

Issue 714273004: mac: Expose keychain access frequency to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock_keychain_sleep
Patch Set: Add a common subclass to measurements. Created 6 years, 1 month 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
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 collections 5 import collections
6 import page_sets 6 import page_sets
7 import re 7 import re
8 8
9 from measurements import PageTestMeasurement
9 from measurements import timeline_controller 10 from measurements import timeline_controller
10 from metrics import speedindex 11 from metrics import speedindex
11 from telemetry import benchmark 12 from telemetry import benchmark
12 from telemetry.core import util 13 from telemetry.core import util
13 from telemetry.page import page_test
14 from telemetry.timeline import async_slice as async_slice_module 14 from telemetry.timeline import async_slice as async_slice_module
15 from telemetry.timeline import slice as slice_module 15 from telemetry.timeline import slice as slice_module
16 from telemetry.value import scalar 16 from telemetry.value import scalar
17 17
18 18
19 class _ServiceWorkerTimelineMetric(object): 19 class _ServiceWorkerTimelineMetric(object):
20 def AddResultsOfCounters(self, process, counter_regex_string, results): 20 def AddResultsOfCounters(self, process, counter_regex_string, results):
21 counter_filter = re.compile(counter_regex_string) 21 counter_filter = re.compile(counter_regex_string)
22 for counter_name, counter in process.counters.iteritems(): 22 for counter_name, counter in process.counters.iteritems():
23 if not counter_filter.search(counter_name): 23 if not counter_filter.search(counter_name):
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 full_name = thread_name + '|' + sanitized_event_name 76 full_name = thread_name + '|' + sanitized_event_name
77 results.AddValue(scalar.ScalarValue( 77 results.AddValue(scalar.ScalarValue(
78 results.current_page, full_name, 'ms', total)) 78 results.current_page, full_name, 'ms', total))
79 results.AddValue(scalar.ScalarValue( 79 results.AddValue(scalar.ScalarValue(
80 results.current_page, full_name + '_max', 'ms', biggest_jank)) 80 results.current_page, full_name + '_max', 'ms', biggest_jank))
81 results.AddValue(scalar.ScalarValue( 81 results.AddValue(scalar.ScalarValue(
82 results.current_page, full_name + '_avg', 'ms', total / len(times))) 82 results.current_page, full_name + '_avg', 'ms', total / len(times)))
83 83
84 84
85 class _ServiceWorkerMeasurement(page_test.PageTest): 85 class _ServiceWorkerMeasurement(PageTestMeasurement):
86 """Measure Speed Index and TRACE_EVENTs""" 86 """Measure Speed Index and TRACE_EVENTs"""
87 87
88 def __init__(self, *args, **kwargs): 88 def __init__(self, *args, **kwargs):
89 super(_ServiceWorkerMeasurement, self).__init__(*args, **kwargs) 89 super(_ServiceWorkerMeasurement, self).__init__(*args, **kwargs)
90 self._timeline_controller = timeline_controller.TimelineController() 90 self._timeline_controller = timeline_controller.TimelineController()
91 self._speed_index = speedindex.SpeedIndexMetric() 91 self._speed_index = speedindex.SpeedIndexMetric()
92 self._page_open_times = collections.defaultdict(int) 92 self._page_open_times = collections.defaultdict(int)
93 93
94 def CustomizeBrowserOptions(self, options): 94 def CustomizeBrowserOptions(self, options):
95 super(_ServiceWorkerMeasurement, self).CustomizeBrowserOptions(options)
95 options.AppendExtraBrowserArgs([ 96 options.AppendExtraBrowserArgs([
96 '--enable-experimental-web-platform-features' 97 '--enable-experimental-web-platform-features'
97 ]) 98 ])
98 99
99 def WillNavigateToPage(self, page, tab): 100 def WillNavigateToPage(self, page, tab):
100 self._timeline_controller.SetUp(page, tab) 101 self._timeline_controller.SetUp(page, tab)
101 self._timeline_controller.Start(tab) 102 self._timeline_controller.Start(tab)
102 self._speed_index.Start(page, tab) 103 self._speed_index.Start(page, tab)
103 104
104 def ValidateAndMeasurePage(self, page, tab, results): 105 def ValidateAndMeasurePage(self, page, tab, results):
105 tab.WaitForDocumentReadyStateToBeComplete(40) 106 tab.WaitForDocumentReadyStateToBeComplete(40)
106 self._timeline_controller.Stop(tab) 107 self._timeline_controller.Stop(tab)
107 108
108 # Retrieve TRACE_EVENTs 109 # Retrieve TRACE_EVENTs
109 timeline_metric = _ServiceWorkerTimelineMetric() 110 timeline_metric = _ServiceWorkerTimelineMetric()
110 browser_process = self._timeline_controller.model.browser_process 111 browser_process = self._timeline_controller.model.browser_process
111 filter_text = '(RegisterServiceWorker|'\ 112 filter_text = '(RegisterServiceWorker|'\
112 'UnregisterServiceWorker|'\ 113 'UnregisterServiceWorker|'\
113 'ProcessAllocate|'\ 114 'ProcessAllocate|'\
114 'FindRegistrationForDocument|'\ 115 'FindRegistrationForDocument|'\
115 'DispatchFetchEvent)' 116 'DispatchFetchEvent)'
116 timeline_metric.AddResultsOfEvents( 117 timeline_metric.AddResultsOfEvents(
117 browser_process, 'IOThread', filter_text , results) 118 browser_process, 'IOThread', filter_text , results)
119 super(_ServiceWorkerMeasurement, self).ValidateAndMeasurePage(
120 page, tab, results)
118 121
119 # Record Speed Index 122 # Record Speed Index
120 def SpeedIndexIsFinished(): 123 def SpeedIndexIsFinished():
121 return self._speed_index.IsFinished(tab) 124 return self._speed_index.IsFinished(tab)
122 util.WaitFor(SpeedIndexIsFinished, 60) 125 util.WaitFor(SpeedIndexIsFinished, 60)
123 self._speed_index.Stop(page, tab) 126 self._speed_index.Stop(page, tab)
124 # Distinguish the first and second load from the subsequent loads 127 # Distinguish the first and second load from the subsequent loads
125 url = str(page) 128 url = str(page)
126 chart_prefix = 'page_load' 129 chart_prefix = 'page_load'
127 self._page_open_times[url] += 1 130 self._page_open_times[url] += 1
128 if self._page_open_times[url] == 1: 131 if self._page_open_times[url] == 1:
129 chart_prefix += '_1st' 132 chart_prefix += '_1st'
130 elif self._page_open_times[url] == 2: 133 elif self._page_open_times[url] == 2:
131 chart_prefix += '_2nd' 134 chart_prefix += '_2nd'
132 else: 135 else:
133 chart_prefix += '_later' 136 chart_prefix += '_later'
134 self._speed_index.AddResults(tab, results, chart_prefix) 137 self._speed_index.AddResults(tab, results, chart_prefix)
135 138
136 139
137 class _ServiceWorkerMicroBenchmarkMeasurement(page_test.PageTest): 140 class _ServiceWorkerMicroBenchmarkMeasurement(PageTestMeasurement):
138 """Measure JS land values and TRACE_EVENTs""" 141 """Measure JS land values and TRACE_EVENTs"""
139 142
140 def __init__(self, *args, **kwargs): 143 def __init__(self, *args, **kwargs):
141 super(_ServiceWorkerMicroBenchmarkMeasurement, self).__init__(*args, 144 super(_ServiceWorkerMicroBenchmarkMeasurement, self).__init__(*args,
142 **kwargs) 145 **kwargs)
143 self._timeline_controller = timeline_controller.TimelineController() 146 self._timeline_controller = timeline_controller.TimelineController()
144 147
145 def CustomizeBrowserOptions(self, options): 148 def CustomizeBrowserOptions(self, options):
149 super(_ServiceWorkerMicroBenchmarkMeasurement, self).\
150 CustomizeBrowserOptions(options)
146 options.AppendExtraBrowserArgs([ 151 options.AppendExtraBrowserArgs([
147 '--enable-experimental-web-platform-features' 152 '--enable-experimental-web-platform-features'
148 ]) 153 ])
149 154
150 def WillNavigateToPage(self, page, tab): 155 def WillNavigateToPage(self, page, tab):
151 self._timeline_controller.SetUp(page, tab) 156 self._timeline_controller.SetUp(page, tab)
152 self._timeline_controller.Start(tab) 157 self._timeline_controller.Start(tab)
153 158
154 def ValidateAndMeasurePage(self, page, tab, results): 159 def ValidateAndMeasurePage(self, page, tab, results):
155 tab.WaitForJavaScriptExpression('window.done', 40) 160 tab.WaitForJavaScriptExpression('window.done', 40)
156 self._timeline_controller.Stop(tab) 161 self._timeline_controller.Stop(tab)
157 162
158 # Measure JavaScript-land 163 # Measure JavaScript-land
159 json = tab.EvaluateJavaScript('window.results || {}') 164 json = tab.EvaluateJavaScript('window.results || {}')
160 for key, value in json.iteritems(): 165 for key, value in json.iteritems():
161 results.AddValue(scalar.ScalarValue( 166 results.AddValue(scalar.ScalarValue(
162 results.current_page, key, value['units'], value['value'])) 167 results.current_page, key, value['units'], value['value']))
163 168
164 # Retrieve TRACE_EVENTs 169 # Retrieve TRACE_EVENTs
165 timeline_metric = _ServiceWorkerTimelineMetric() 170 timeline_metric = _ServiceWorkerTimelineMetric()
166 browser_process = self._timeline_controller.model.browser_process 171 browser_process = self._timeline_controller.model.browser_process
167 filter_text = '(RegisterServiceWorker|'\ 172 filter_text = '(RegisterServiceWorker|'\
168 'UnregisterServiceWorker|'\ 173 'UnregisterServiceWorker|'\
169 'ProcessAllocate|'\ 174 'ProcessAllocate|'\
170 'FindRegistrationForDocument|'\ 175 'FindRegistrationForDocument|'\
171 'DispatchFetchEvent)' 176 'DispatchFetchEvent)'
172 timeline_metric.AddResultsOfEvents( 177 timeline_metric.AddResultsOfEvents(
173 browser_process, 'IOThread', filter_text , results) 178 browser_process, 'IOThread', filter_text , results)
179 super(_ServiceWorkerMicroBenchmarkMeasurement, self).ValidateAndMeasurePage(
180 page, tab, results)
174 181
175 182
176 @benchmark.Enabled('android') 183 @benchmark.Enabled('android')
177 class ServiceWorkerPerfTest(benchmark.Benchmark): 184 class ServiceWorkerPerfTest(benchmark.Benchmark):
178 """Performance test on public applications using ServiceWorker""" 185 """Performance test on public applications using ServiceWorker"""
179 test = _ServiceWorkerMeasurement 186 test = _ServiceWorkerMeasurement
180 page_set = page_sets.ServiceWorkerPageSet 187 page_set = page_sets.ServiceWorkerPageSet
181 188
182 189
183 # FIXME(nhiroki): Temporary disable the benchmark (http://crbug.com/430232). 190 # FIXME(nhiroki): Temporary disable the benchmark (http://crbug.com/430232).
184 @benchmark.Disabled 191 @benchmark.Disabled
185 class ServiceWorkerMicroBenchmarkPerfTest(benchmark.Benchmark): 192 class ServiceWorkerMicroBenchmarkPerfTest(benchmark.Benchmark):
186 """Service Worker performance test using a micro benchmark page set""" 193 """Service Worker performance test using a micro benchmark page set"""
187 test = _ServiceWorkerMicroBenchmarkMeasurement 194 test = _ServiceWorkerMicroBenchmarkMeasurement
188 page_set = page_sets.ServiceWorkerMicroBenchmarkPageSet 195 page_set = page_sets.ServiceWorkerMicroBenchmarkPageSet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698