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

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

Issue 809393002: Added support for improvement_direction to relevant values, which is propogated to chartjson. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix linter issues Created 5 years, 11 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
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 timeline_controller 9 from measurements import timeline_controller
10 from metrics import speedindex 10 from metrics import speedindex
11 from telemetry import benchmark 11 from telemetry import benchmark
12 from telemetry.core import util 12 from telemetry.core import util
13 from telemetry.page import page_test 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 improvement_direction
16 from telemetry.value import scalar 17 from telemetry.value import scalar
17 18
18 19
19 class _ServiceWorkerTimelineMetric(object): 20 class _ServiceWorkerTimelineMetric(object):
20 def AddResultsOfCounters(self, process, counter_regex_string, results): 21 def AddResultsOfCounters(self, process, counter_regex_string, results):
21 counter_filter = re.compile(counter_regex_string) 22 counter_filter = re.compile(counter_regex_string)
22 for counter_name, counter in process.counters.iteritems(): 23 for counter_name, counter in process.counters.iteritems():
23 if not counter_filter.search(counter_name): 24 if not counter_filter.search(counter_name):
24 continue 25 continue
25 26
26 total = sum(counter.totals) 27 total = sum(counter.totals)
27 28
28 # Results objects cannot contain the '.' character, so remove that here. 29 # Results objects cannot contain the '.' character, so remove that here.
29 sanitized_counter_name = counter_name.replace('.', '_') 30 sanitized_counter_name = counter_name.replace('.', '_')
30 31
31 results.AddValue(scalar.ScalarValue( 32 results.AddValue(scalar.ScalarValue(
32 results.current_page, sanitized_counter_name, 'count', total)) 33 results.current_page, sanitized_counter_name, 'count', total,
34 improvement_direction=improvement_direction.DOWN))
33 results.AddValue(scalar.ScalarValue( 35 results.AddValue(scalar.ScalarValue(
34 results.current_page, sanitized_counter_name + '_avg', 'count', 36 results.current_page, sanitized_counter_name + '_avg', 'count',
35 total / float(len(counter.totals)))) 37 total / float(len(counter.totals)),
38 improvement_direction=improvement_direction.DOWN))
36 39
37 def AddResultsOfEvents( 40 def AddResultsOfEvents(
38 self, process, thread_regex_string, event_regex_string, results): 41 self, process, thread_regex_string, event_regex_string, results):
39 thread_filter = re.compile(thread_regex_string) 42 thread_filter = re.compile(thread_regex_string)
40 event_filter = re.compile(event_regex_string) 43 event_filter = re.compile(event_regex_string)
41 44
42 for thread in process.threads.itervalues(): 45 for thread in process.threads.itervalues():
43 thread_name = thread.name.replace('/', '_') 46 thread_name = thread.name.replace('/', '_')
44 if not thread_filter.search(thread_name): 47 if not thread_filter.search(thread_name):
45 continue 48 continue
(...skipping 22 matching lines...) Expand all
68 71
69 def _AddResultOfEvent(self, thread_name, event_name, times, results): 72 def _AddResultOfEvent(self, thread_name, event_name, times, results):
70 total = sum(times) 73 total = sum(times)
71 biggest_jank = max(times) 74 biggest_jank = max(times)
72 75
73 # Results objects cannot contain the '.' character, so remove that here. 76 # Results objects cannot contain the '.' character, so remove that here.
74 sanitized_event_name = event_name.replace('.', '_') 77 sanitized_event_name = event_name.replace('.', '_')
75 78
76 full_name = thread_name + '|' + sanitized_event_name 79 full_name = thread_name + '|' + sanitized_event_name
77 results.AddValue(scalar.ScalarValue( 80 results.AddValue(scalar.ScalarValue(
78 results.current_page, full_name, 'ms', total)) 81 results.current_page, full_name, 'ms', total,
82 improvement_direction=improvement_direction.DOWN))
79 results.AddValue(scalar.ScalarValue( 83 results.AddValue(scalar.ScalarValue(
80 results.current_page, full_name + '_max', 'ms', biggest_jank)) 84 results.current_page, full_name + '_max', 'ms', biggest_jank,
85 improvement_direction=improvement_direction.DOWN))
81 results.AddValue(scalar.ScalarValue( 86 results.AddValue(scalar.ScalarValue(
82 results.current_page, full_name + '_avg', 'ms', total / len(times))) 87 results.current_page, full_name + '_avg', 'ms', total / len(times),
88 improvement_direction=improvement_direction.DOWN))
83 89
84 90
85 class _ServiceWorkerMeasurement(page_test.PageTest): 91 class _ServiceWorkerMeasurement(page_test.PageTest):
86 """Measure Speed Index and TRACE_EVENTs""" 92 """Measure Speed Index and TRACE_EVENTs"""
87 93
88 def __init__(self): 94 def __init__(self):
89 super(_ServiceWorkerMeasurement, self).__init__( 95 super(_ServiceWorkerMeasurement, self).__init__(
90 action_name_to_run='RunPageInteractions') 96 action_name_to_run='RunPageInteractions')
91 self._timeline_controller = timeline_controller.TimelineController() 97 self._timeline_controller = timeline_controller.TimelineController()
92 self._speed_index = speedindex.SpeedIndexMetric() 98 self._speed_index = speedindex.SpeedIndexMetric()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 self._timeline_controller.Start(tab) 159 self._timeline_controller.Start(tab)
154 160
155 def ValidateAndMeasurePage(self, page, tab, results): 161 def ValidateAndMeasurePage(self, page, tab, results):
156 tab.WaitForJavaScriptExpression('window.done', 40) 162 tab.WaitForJavaScriptExpression('window.done', 40)
157 self._timeline_controller.Stop(tab, results) 163 self._timeline_controller.Stop(tab, results)
158 164
159 # Measure JavaScript-land 165 # Measure JavaScript-land
160 json = tab.EvaluateJavaScript('window.results || {}') 166 json = tab.EvaluateJavaScript('window.results || {}')
161 for key, value in json.iteritems(): 167 for key, value in json.iteritems():
162 results.AddValue(scalar.ScalarValue( 168 results.AddValue(scalar.ScalarValue(
163 results.current_page, key, value['units'], value['value'])) 169 results.current_page, key, value['units'], value['value'],
170 improvement_direction=improvement_direction.DOWN))
164 171
165 # Retrieve TRACE_EVENTs 172 # Retrieve TRACE_EVENTs
166 timeline_metric = _ServiceWorkerTimelineMetric() 173 timeline_metric = _ServiceWorkerTimelineMetric()
167 browser_process = self._timeline_controller.model.browser_process 174 browser_process = self._timeline_controller.model.browser_process
168 filter_text = '(RegisterServiceWorker|'\ 175 filter_text = '(RegisterServiceWorker|'\
169 'UnregisterServiceWorker|'\ 176 'UnregisterServiceWorker|'\
170 'ProcessAllocate|'\ 177 'ProcessAllocate|'\
171 'FindRegistrationForDocument|'\ 178 'FindRegistrationForDocument|'\
172 'DispatchFetchEvent)' 179 'DispatchFetchEvent)'
173 timeline_metric.AddResultsOfEvents( 180 timeline_metric.AddResultsOfEvents(
(...skipping 12 matching lines...) Expand all
186 """This test measures the performance of pages using ServiceWorker. 193 """This test measures the performance of pages using ServiceWorker.
187 194
188 As a page set, two benchamrk pages (many registration, many concurrent 195 As a page set, two benchamrk pages (many registration, many concurrent
189 fetching) and one application (Trained-to-thrill: 196 fetching) and one application (Trained-to-thrill:
190 https://jakearchibald.github.io/trained-to-thrill/) are included. Execution 197 https://jakearchibald.github.io/trained-to-thrill/) are included. Execution
191 time of these pages will be shown as Speed Index, and TRACE_EVENTs are 198 time of these pages will be shown as Speed Index, and TRACE_EVENTs are
192 subsidiary information to know more detail performance regression. 199 subsidiary information to know more detail performance regression.
193 """ 200 """
194 test = _ServiceWorkerMicroBenchmarkMeasurement 201 test = _ServiceWorkerMicroBenchmarkMeasurement
195 page_set = page_sets.ServiceWorkerMicroBenchmarkPageSet 202 page_set = page_sets.ServiceWorkerMicroBenchmarkPageSet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698