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

Side by Side Diff: tools/perf/measurements/smoothness_controller.py

Issue 814813003: Added test that SurfaceFlinger metrics are calculated on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PLEASE IGNORE: accidentally uploaded to wrong issue Created 5 years, 12 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/perf/measurements/smoothness_unittest.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 import sys 4 import sys
5 5
6 from measurements import smooth_gesture_util 6 from measurements import smooth_gesture_util
7 from telemetry.core.platform import tracing_category_filter 7 from telemetry.core.platform import tracing_category_filter
8 from telemetry.core.platform import tracing_options 8 from telemetry.core.platform import tracing_options
9 from telemetry.timeline import trace_data as trace_data_module
9 from telemetry.timeline.model import TimelineModel 10 from telemetry.timeline.model import TimelineModel
10 from telemetry.page import page_test 11 from telemetry.page import page_test
11 from telemetry.page.actions import action_runner 12 from telemetry.page.actions import action_runner
12 from telemetry.value import list_of_scalar_values 13 from telemetry.value import list_of_scalar_values
13 from telemetry.value import scalar 14 from telemetry.value import scalar
14 from telemetry.value import trace 15 from telemetry.value import trace
15 from telemetry.web_perf import timeline_interaction_record as tir_module 16 from telemetry.web_perf import timeline_interaction_record as tir_module
16 from telemetry.web_perf.metrics import smoothness 17 from telemetry.web_perf.metrics import smoothness
17 18
18 19
19 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' 20 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions'
20 21
21 22
22 class SmoothnessController(object): 23 class SmoothnessController(object):
23 def __init__(self): 24 def __init__(self):
24 self._timeline_model = None 25 self._timeline_model = None
25 self._tracing_timeline_data = None 26 self._trace_data = None
26 self._interaction = None 27 self._interaction = None
27 self._surface_flinger_timeline_data = None 28 self._surface_flinger_trace_data = None
28 29
29 def SetUp(self, page, tab): 30 def SetUp(self, page, tab):
30 # FIXME: Remove webkit.console when blink.console lands in chromium and 31 # FIXME: Remove webkit.console when blink.console lands in chromium and
31 # the ref builds are updated. crbug.com/386847 32 # the ref builds are updated. crbug.com/386847
32 custom_categories = ['webkit.console', 'blink.console', 'benchmark'] 33 custom_categories = ['webkit.console', 'blink.console', 'benchmark']
33 custom_categories += page.GetSyntheticDelayCategories() 34 custom_categories += page.GetSyntheticDelayCategories()
34 category_filter = tracing_category_filter.TracingCategoryFilter() 35 category_filter = tracing_category_filter.TracingCategoryFilter()
35 for c in custom_categories: 36 for c in custom_categories:
36 category_filter.AddIncludedCategory(c) 37 category_filter.AddIncludedCategory(c)
37 options = tracing_options.TracingOptions() 38 options = tracing_options.TracingOptions()
38 options.enable_chrome_trace = True 39 options.enable_chrome_trace = True
39 tab.browser.platform.tracing_controller.Start(options, category_filter, 60) 40 tab.browser.platform.tracing_controller.Start(options, category_filter, 60)
40 if tab.browser.platform.IsDisplayTracingSupported(): 41 if tab.browser.platform.IsDisplayTracingSupported():
41 tab.browser.platform.StartDisplayTracing(); 42 tab.browser.platform.StartDisplayTracing();
42 43
43 def Start(self, tab): 44 def Start(self, tab):
44 # Start the smooth marker for all smooth actions. 45 # Start the smooth marker for all smooth actions.
45 runner = action_runner.ActionRunner(tab) 46 runner = action_runner.ActionRunner(tab)
46 self._interaction = runner.BeginInteraction( 47 self._interaction = runner.BeginInteraction(
47 RUN_SMOOTH_ACTIONS, is_smooth=True) 48 RUN_SMOOTH_ACTIONS, is_smooth=True)
48 49
49 def Stop(self, tab): 50 def Stop(self, tab):
50 # End the smooth marker for all smooth actions. 51 # End the smooth marker for all smooth actions.
51 self._interaction.End() 52 self._interaction.End()
52 # Stop tracing for smoothness metric. 53 # Stop tracing for smoothness metric.
53 if tab.browser.platform.IsDisplayTracingSupported(): 54 if tab.browser.platform.IsDisplayTracingSupported():
54 self._surface_flinger_timeline_data = \ 55 self._surface_flinger_trace_data = \
55 tab.browser.platform.StopDisplayTracing() 56 tab.browser.platform.StopDisplayTracing()
56 self._tracing_timeline_data = tab.browser.platform.tracing_controller.Stop() 57 self._trace_data = tab.browser.platform.tracing_controller.Stop()
57 timeline_data = [self._tracing_timeline_data] 58 trace_data_builder = trace_data_module.TraceDataBuilder()
58 if self._surface_flinger_timeline_data: 59 for part in self._trace_data.active_parts:
59 timeline_data.append(self._surface_flinger_timeline_data) 60 trace_data_builder.AddEventsTo(part, self._trace_data.GetEventsFor(part))
60 self._timeline_model = TimelineModel( 61 if self._surface_flinger_trace_data:
61 timeline_data=timeline_data) 62 trace_data_builder.AddEventsTo(
63 trace_data_module.SURFACE_FLINGER_PART,
64 self._surface_flinger_trace_data.GetEventsFor(
65 trace_data_module.SURFACE_FLINGER_PART))
66 self._timeline_model = TimelineModel(trace_data_builder.AsData())
62 67
63 def AddResults(self, tab, results): 68 def AddResults(self, tab, results):
64 # Add results of smoothness metric. This computes the smoothness metric for 69 # Add results of smoothness metric. This computes the smoothness metric for
65 # the time ranges of gestures, if there is at least one, else the the time 70 # the time ranges of gestures, if there is at least one, else the the time
66 # ranges from the first action to the last action. 71 # ranges from the first action to the last action.
67 results.AddValue(trace.TraceValue( 72 results.AddValue(trace.TraceValue(
68 results.current_page, self._tracing_timeline_data)) 73 results.current_page, self._trace_data))
69 renderer_thread = self._timeline_model.GetRendererThreadFromTabId( 74 renderer_thread = self._timeline_model.GetRendererThreadFromTabId(
70 tab.id) 75 tab.id)
71 run_smooth_actions_record = None 76 run_smooth_actions_record = None
72 smooth_records = [] 77 smooth_records = []
73 for event in renderer_thread.async_slices: 78 for event in renderer_thread.async_slices:
74 if not tir_module.IsTimelineInteractionRecord(event.name): 79 if not tir_module.IsTimelineInteractionRecord(event.name):
75 continue 80 continue
76 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) 81 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
77 if r.label == RUN_SMOOTH_ACTIONS: 82 if r.label == RUN_SMOOTH_ACTIONS:
78 assert run_smooth_actions_record is None, ( 83 assert run_smooth_actions_record is None, (
79 'SmoothnessController cannot issue more than 1 %s record' % 84 'SmoothnessController cannot issue more than 1 %s record' %
80 RUN_SMOOTH_ACTIONS) 85 RUN_SMOOTH_ACTIONS)
81 run_smooth_actions_record = r 86 run_smooth_actions_record = r
82 elif r.is_smooth: 87 elif r.is_smooth:
83 smooth_records.append( 88 smooth_records.append(
84 smooth_gesture_util.GetAdjustedInteractionIfContainGesture( 89 smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
85 self._timeline_model, r)) 90 self._timeline_model, r))
86 91
87 # If there is no other smooth records, we make measurements on time range 92 # If there is no other smooth records, we make measurements on time range
88 # marked smoothness_controller itself. 93 # marked smoothness_controller itself.
89 # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that 94 # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
90 # page sets are responsible for issueing the markers themselves. 95 # page sets are responsible for issueing the markers themselves.
91 if len(smooth_records) == 0: 96 if len(smooth_records) == 0:
92 if run_smooth_actions_record is None: 97 if run_smooth_actions_record is None:
93 sys.stderr.write('Raw tracing data:\n') 98 sys.stderr.write('Raw tracing data:\n')
94 sys.stderr.write(repr(self._tracing_timeline_data.EventData())) 99 self._trace_data.Serialize(sys.stderr)
95 sys.stderr.write('\n') 100 sys.stderr.write('\n')
96 raise Exception('SmoothnessController failed to issue markers for the ' 101 raise Exception('SmoothnessController failed to issue markers for the '
97 'whole interaction.') 102 'whole interaction.')
98 else: 103 else:
99 smooth_records = [run_smooth_actions_record] 104 smooth_records = [run_smooth_actions_record]
100 105
101 # Create an interaction_record for this legacy measurement. Since we don't 106 # Create an interaction_record for this legacy measurement. Since we don't
102 # wrap the results that are sent to smoothness metric, the label will 107 # wrap the results that are sent to smoothness metric, the label will
103 # not be used. 108 # not be used.
104 smoothness_metric = smoothness.SmoothnessMetric() 109 smoothness_metric = smoothness.SmoothnessMetric()
105 smoothness_metric.AddResults( 110 smoothness_metric.AddResults(
106 self._timeline_model, renderer_thread, smooth_records, results) 111 self._timeline_model, renderer_thread, smooth_records, results)
107 112
108 def CleanUp(self, tab): 113 def CleanUp(self, tab):
109 if tab.browser.platform.IsDisplayTracingSupported(): 114 if tab.browser.platform.IsDisplayTracingSupported():
110 tab.browser.platform.StopDisplayTracing() 115 tab.browser.platform.StopDisplayTracing()
111 if tab.browser.platform.tracing_controller.is_tracing_running: 116 if tab.browser.platform.tracing_controller.is_tracing_running:
112 tab.browser.platform.tracing_controller.Stop() 117 tab.browser.platform.tracing_controller.Stop()
OLDNEW
« no previous file with comments | « no previous file | tools/perf/measurements/smoothness_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698