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

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

Issue 313383002: Cleanup interaction creation and add ExecuteJavaScript to action_runner.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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/timeline_controller.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.timeline.model import TimelineModel 7 from telemetry.core.timeline.model import TimelineModel
8 from telemetry.page import page_measurement 8 from telemetry.page import page_measurement
9 from telemetry.page.actions import action_runner 9 from telemetry.page.actions import action_runner
10 from telemetry.web_perf import timeline_interaction_record as tir_module 10 from telemetry.web_perf import timeline_interaction_record as tir_module
11 from telemetry.web_perf.metrics import smoothness 11 from telemetry.web_perf.metrics import smoothness
12 12
13 13
14 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' 14 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions'
15 15
16 16
17 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): 17 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure):
18 def __init__(self, name): 18 def __init__(self, name):
19 super(MissingDisplayFrameRateError, self).__init__( 19 super(MissingDisplayFrameRateError, self).__init__(
20 'Missing display frame rate metrics: ' + name) 20 'Missing display frame rate metrics: ' + name)
21 21
22 class SmoothnessController(object): 22 class SmoothnessController(object):
23 def __init__(self): 23 def __init__(self):
24 self._timeline_model = None 24 self._timeline_model = None
25 self._tracing_timeline_data = None 25 self._tracing_timeline_data = None
26 self._interaction = None
26 27
27 def Start(self, page, tab): 28 def Start(self, page, tab):
28 custom_categories = ['webkit.console', 'benchmark'] 29 custom_categories = ['webkit.console', 'benchmark']
29 custom_categories += page.GetSyntheticDelayCategories() 30 custom_categories += page.GetSyntheticDelayCategories()
30 tab.browser.StartTracing(','.join(custom_categories), 60) 31 tab.browser.StartTracing(','.join(custom_categories), 60)
31 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 32 if tab.browser.platform.IsRawDisplayFrameRateSupported():
32 tab.browser.platform.StartRawDisplayFrameRateMeasurement() 33 tab.browser.platform.StartRawDisplayFrameRateMeasurement()
33 # Start the smooth marker for all smooth actions. 34 # Start the smooth marker for all smooth actions.
34 runner = action_runner.ActionRunner(tab) 35 runner = action_runner.ActionRunner(tab)
35 runner.BeginInteraction(RUN_SMOOTH_ACTIONS, [tir_module.IS_SMOOTH]) 36 self._interaction = runner.BeginInteraction(
37 RUN_SMOOTH_ACTIONS, is_smooth=True)
36 38
37 def Stop(self, tab): 39 def Stop(self, tab):
38 # End the smooth marker for all smooth actions. 40 # End the smooth marker for all smooth actions.
39 runner = action_runner.ActionRunner(tab) 41 self._interaction.End()
40 runner.EndInteraction(RUN_SMOOTH_ACTIONS, [tir_module.IS_SMOOTH])
41 # Stop tracing for smoothness metric. 42 # Stop tracing for smoothness metric.
42 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 43 if tab.browser.platform.IsRawDisplayFrameRateSupported():
43 tab.browser.platform.StopRawDisplayFrameRateMeasurement() 44 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
44 self._tracing_timeline_data = tab.browser.StopTracing() 45 self._tracing_timeline_data = tab.browser.StopTracing()
45 self._timeline_model = TimelineModel( 46 self._timeline_model = TimelineModel(
46 timeline_data=self._tracing_timeline_data) 47 timeline_data=self._tracing_timeline_data)
47 48
48 def AddResults(self, tab, results): 49 def AddResults(self, tab, results):
49 # Add results of smoothness metric. This computes the smoothness metric for 50 # Add results of smoothness metric. This computes the smoothness metric for
50 # the time ranges of gestures, if there is at least one, else the the time 51 # the time ranges of gestures, if there is at least one, else the the time
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): 92 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
92 if r.value is None: 93 if r.value is None:
93 raise MissingDisplayFrameRateError(r.name) 94 raise MissingDisplayFrameRateError(r.name)
94 results.Add(r.name, r.unit, r.value) 95 results.Add(r.name, r.unit, r.value)
95 96
96 def CleanUp(self, tab): 97 def CleanUp(self, tab):
97 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 98 if tab.browser.platform.IsRawDisplayFrameRateSupported():
98 tab.browser.platform.StopRawDisplayFrameRateMeasurement() 99 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
99 if tab.browser.is_tracing_running: 100 if tab.browser.is_tracing_running:
100 tab.browser.StopTracing() 101 tab.browser.StopTracing()
OLDNEW
« no previous file with comments | « no previous file | tools/perf/measurements/timeline_controller.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698