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

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

Issue 2819343002: Support tracing metrics for measureTime & measureFrameTime method in blink_perf (Closed)
Patch Set: Split StartTracing & StopTracing Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 os 5 import os
6 6
7 from core import path_util 7 from core import path_util
8 from core import perf_benchmark 8 from core import perf_benchmark
9 9
10 from telemetry import benchmark 10 from telemetry import benchmark
11 from telemetry import page as page_module 11 from telemetry import page as page_module
12 from telemetry.page import legacy_page_test 12 from telemetry.page import legacy_page_test
13 from telemetry.page import shared_page_state 13 from telemetry.page import shared_page_state
14 from telemetry import story 14 from telemetry import story
15 from telemetry.timeline import bounds
16 from telemetry.timeline import model as model_module
17 from telemetry.timeline import tracing_config
18
15 from telemetry.value import list_of_scalar_values 19 from telemetry.value import list_of_scalar_values
16 from telemetry.value import scalar 20 from telemetry.value import scalar
21 from telemetry.value import trace
22
17 23
18 from benchmarks import pywebsocket_server 24 from benchmarks import pywebsocket_server
19 from measurements import timeline_controller 25 from measurements import timeline_controller
20 from page_sets import webgl_supported_shared_state 26 from page_sets import webgl_supported_shared_state
21 27
22 28
23 BLINK_PERF_BASE_DIR = os.path.join(path_util.GetChromiumSrcDir(), 29 BLINK_PERF_BASE_DIR = os.path.join(path_util.GetChromiumSrcDir(),
24 'third_party', 'WebKit', 'PerformanceTests') 30 'third_party', 'WebKit', 'PerformanceTests')
25 SKIPPED_FILE = os.path.join(BLINK_PERF_BASE_DIR, 'Skipped') 31 SKIPPED_FILE = os.path.join(BLINK_PERF_BASE_DIR, 'Skipped')
26 32
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 '--js-flags=--expose_gc', 97 '--js-flags=--expose_gc',
92 '--enable-experimental-web-platform-features', 98 '--enable-experimental-web-platform-features',
93 '--disable-gesture-requirement-for-media-playback', 99 '--disable-gesture-requirement-for-media-playback',
94 '--enable-experimental-canvas-features', 100 '--enable-experimental-canvas-features',
95 # TODO(qinmin): After fixing crbug.com/592017, remove this command line. 101 # TODO(qinmin): After fixing crbug.com/592017, remove this command line.
96 '--reduce-security-for-testing' 102 '--reduce-security-for-testing'
97 ]) 103 ])
98 if 'content-shell' in options.browser_type: 104 if 'content-shell' in options.browser_type:
99 options.AppendExtraBrowserArgs('--expose-internals-for-testing') 105 options.AppendExtraBrowserArgs('--expose-internals-for-testing')
100 106
107 def _ContinueTestRunWithTracing(self, tab):
108 tracing_categories = tab.EvaluateJavaScript(
109 'testRunner.tracingCategories')
110 config = tracing_config.TracingConfig()
111 config.enable_chrome_trace = True
112 config.chrome_trace_config.category_filter.AddFilterString(
113 'blink.console') # This is always required for js land trace event
114 config.chrome_trace_config.category_filter.AddFilterString(
115 tracing_categories)
116 tab.browser.platform.tracing_controller.StartTracing(config)
117 tab.EvaluateJavaScript('testRunner.scheduleTestRun()')
118 tab.WaitForJavaScriptCondition('testRunner.isDone')
119 return tab.browser.platform.tracing_controller.StopTracing()
120
121 def _ComputeTraceEventsThreadTime(self, trace_results,
122 trace_events_to_measure, tab_id):
123 trace_cpu_time_metrics = {}
124
125 # Collect the bounds of "blink_perf.runTest" events.
126 model = model_module.TimelineModel(trace_results)
127 renderer_thread = model.GetRendererThreadFromTabId(tab_id)
128 test_runs_bounds = []
129 for event in renderer_thread.async_slices:
130 if event.name == "blink_perf.runTest":
131 test_runs_bounds.append(bounds.Bounds.CreateFromEvent(event))
132 test_runs_bounds.sort(key=lambda b: b.min)
133
134 for t in trace_events_to_measure:
135 trace_cpu_time_metrics[t] = [0.0] * len(test_runs_bounds)
136
137 for event_name in trace_events_to_measure:
138 curr_test_runs_bound_index = 0
139 for event in renderer_thread.IterAllSlicesOfName(event_name):
140 while (curr_test_runs_bound_index < len(test_runs_bounds) and
141 event.start > test_runs_bounds[curr_test_runs_bound_index].max):
142 curr_test_runs_bound_index += 1
143 if curr_test_runs_bound_index >= len(test_runs_bounds):
144 break
145 curr_test_bound = test_runs_bounds[curr_test_runs_bound_index]
146 intersect_wall_time = bounds.Bounds.GetOverlapBetweenBounds(
147 curr_test_bound, bounds.Bounds.CreateFromEvent(event))
148 intersect_cpu_time = (
149 intersect_wall_time * event.thread_duration / event.duration)
150 trace_cpu_time_metrics[event_name][curr_test_runs_bound_index] += (
151 intersect_cpu_time)
152
153 return trace_cpu_time_metrics
154
155 def PrintAndCollectTraceEventMetrics(self, trace_cpu_time_metrics, results):
156 unit = 'ms'
157 print
158 for trace_event_name, cpu_times in trace_cpu_time_metrics.iteritems():
159 print 'CPU times of trace event "%s":' % trace_event_name
160 cpu_times_string = ', '.join(['{0:.10f}'.format(t) for t in cpu_times])
161 print 'values %s %s' % (cpu_times_string, unit)
162 avg = 0.0
163 if cpu_times:
164 avg = sum(cpu_times)/len(cpu_times)
165 print 'avg', '{0:.10f}'.format(avg), unit
166 results.AddValue(list_of_scalar_values.ListOfScalarValues(
167 results.current_page, name=trace_event_name, units=unit,
168 values=cpu_times))
169 print
170 print '\n'
171
101 def ValidateAndMeasurePage(self, page, tab, results): 172 def ValidateAndMeasurePage(self, page, tab, results):
102 tab.WaitForJavaScriptCondition('testRunner.isDone', timeout=600) 173 tab.WaitForJavaScriptCondition(
174 'testRunner.isDone || testRunner.isWaitingForTracingStart', timeout=600)
175 trace_cpu_time_metrics = {}
176 if tab.EvaluateJavaScript('testRunner.isWaitingForTracingStart'):
177 trace_result = self._ContinueTestRunWithTracing(tab)
178 trace_value = trace.TraceValue(page, trace_result)
179 results.AddValue(trace_value)
180 trace_events_to_measure = tab.EvaluateJavaScript(
181 'window.testRunner.traceEventsToMeasure')
182 trace_cpu_time_metrics = self._ComputeTraceEventsThreadTime(
183 trace_result, trace_events_to_measure, tab.id)
103 184
104 log = tab.EvaluateJavaScript('document.getElementById("log").innerHTML') 185 log = tab.EvaluateJavaScript('document.getElementById("log").innerHTML')
105 186
106 for line in log.splitlines(): 187 for line in log.splitlines():
107 if line.startswith("FATAL: "): 188 if line.startswith("FATAL: "):
108 print line 189 print line
109 continue 190 continue
110 if not line.startswith('values '): 191 if not line.startswith('values '):
111 continue 192 continue
112 parts = line.split() 193 parts = line.split()
113 values = [float(v.replace(',', '')) for v in parts[1:-1]] 194 values = [float(v.replace(',', '')) for v in parts[1:-1]]
114 units = parts[-1] 195 units = parts[-1]
115 metric = page.display_name.split('.')[0].replace('/', '_') 196 metric = page.display_name.split('.')[0].replace('/', '_')
116 results.AddValue(list_of_scalar_values.ListOfScalarValues( 197 results.AddValue(list_of_scalar_values.ListOfScalarValues(
117 results.current_page, metric, units, values)) 198 results.current_page, metric, units, values))
118 199
119 break 200 break
120 201
121 print log 202 print log
122 203
204 self.PrintAndCollectTraceEventMetrics(trace_cpu_time_metrics, results)
205
123 206
124 # TODO(wangxianzhu): Convert the paint benchmarks to use the new blink_perf 207 # TODO(wangxianzhu): Convert the paint benchmarks to use the new blink_perf
125 # tracing once it's ready. 208 # tracing once it's ready.
126 class _BlinkPerfPaintMeasurement(_BlinkPerfMeasurement): 209 class _BlinkPerfPaintMeasurement(_BlinkPerfMeasurement):
127 """Also collects prePaint and paint timing from traces.""" 210 """Also collects prePaint and paint timing from traces."""
128 211
129 def __init__(self): 212 def __init__(self):
130 super(_BlinkPerfPaintMeasurement, self).__init__() 213 super(_BlinkPerfPaintMeasurement, self).__init__()
131 self._controller = None 214 self._controller = None
132 215
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 276
194 @classmethod 277 @classmethod
195 def ShouldDisable(cls, possible_browser): 278 def ShouldDisable(cls, possible_browser):
196 # http://crbug.com/563979 279 # http://crbug.com/563979
197 return (cls.IsSvelte(possible_browser) 280 return (cls.IsSvelte(possible_browser)
198 # http://crbug.com/653970 281 # http://crbug.com/653970
199 or (possible_browser.browser_type == 'reference' and 282 or (possible_browser.browser_type == 'reference' and
200 possible_browser.platform.GetOSName() == 'android')) 283 possible_browser.platform.GetOSName() == 'android'))
201 284
202 285
286 #TODO(nednguyen): remove this before landing code
287 class BlinkPerfTest(_BlinkPerfBenchmark):
288 tag = 'testing'
289 subdir = 'TestData'
290
291
203 @benchmark.Enabled('content-shell') 292 @benchmark.Enabled('content-shell')
204 class BlinkPerfBlinkGC(_BlinkPerfBenchmark): 293 class BlinkPerfBlinkGC(_BlinkPerfBenchmark):
205 tag = 'blink_gc' 294 tag = 'blink_gc'
206 subdir = 'BlinkGC' 295 subdir = 'BlinkGC'
207 296
208 297
209 @benchmark.Owner(emails=['rune@opera.com']) 298 @benchmark.Owner(emails=['rune@opera.com'])
210 class BlinkPerfCSS(_BlinkPerfBenchmark): 299 class BlinkPerfCSS(_BlinkPerfBenchmark):
211 tag = 'css' 300 tag = 'css'
212 subdir = 'CSS' 301 subdir = 'CSS'
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 411
323 def CreateStorySet(self, options): 412 def CreateStorySet(self, options):
324 path = os.path.join(BLINK_PERF_BASE_DIR, self.subdir) 413 path = os.path.join(BLINK_PERF_BASE_DIR, self.subdir)
325 return CreateStorySetFromPath( 414 return CreateStorySetFromPath(
326 path, SKIPPED_FILE, 415 path, SKIPPED_FILE,
327 shared_page_state_class=_SharedPywebsocketPageState) 416 shared_page_state_class=_SharedPywebsocketPageState)
328 417
329 @classmethod 418 @classmethod
330 def ShouldDisable(cls, possible_browser): 419 def ShouldDisable(cls, possible_browser):
331 return cls.IsSvelte(possible_browser) # http://crbug.com/551950 420 return cls.IsSvelte(possible_browser) # http://crbug.com/551950
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698