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

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

Issue 386023004: Cleanup while reading code: Move GetJavaScriptMarker to be a free function instead of static functi… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix tests. Created 6 years, 5 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 import sys 4 import sys
5 5
6 from measurements import smooth_gesture_util 6 from measurements import smooth_gesture_util
7 from telemetry.timeline.model import TimelineModel 7 from telemetry.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.value import list_of_scalar_values 10 from telemetry.value import list_of_scalar_values
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 # ranges from the first action to the last action. 56 # ranges from the first action to the last action.
57 57
58 renderer_thread = self._timeline_model.GetRendererThreadFromTabId( 58 renderer_thread = self._timeline_model.GetRendererThreadFromTabId(
59 tab.id) 59 tab.id)
60 run_smooth_actions_record = None 60 run_smooth_actions_record = None
61 smooth_records = [] 61 smooth_records = []
62 for event in renderer_thread.async_slices: 62 for event in renderer_thread.async_slices:
63 if not tir_module.IsTimelineInteractionRecord(event.name): 63 if not tir_module.IsTimelineInteractionRecord(event.name):
64 continue 64 continue
65 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) 65 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
66 if r.logical_name == RUN_SMOOTH_ACTIONS: 66 if r.label == RUN_SMOOTH_ACTIONS:
67 assert run_smooth_actions_record is None, ( 67 assert run_smooth_actions_record is None, (
68 'SmoothnessController cannot issue more than 1 %s record' % 68 'SmoothnessController cannot issue more than 1 %s record' %
69 RUN_SMOOTH_ACTIONS) 69 RUN_SMOOTH_ACTIONS)
70 run_smooth_actions_record = r 70 run_smooth_actions_record = r
71 elif r.is_smooth: 71 elif r.is_smooth:
72 smooth_records.append( 72 smooth_records.append(
73 smooth_gesture_util.GetAdjustedInteractionIfContainGesture( 73 smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
74 self._timeline_model, r)) 74 self._timeline_model, r))
75 75
76 # If there is no other smooth records, we make measurements on time range 76 # If there is no other smooth records, we make measurements on time range
77 # marked smoothness_controller itself. 77 # marked smoothness_controller itself.
78 # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that 78 # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
79 # page sets are responsible for issueing the markers themselves. 79 # page sets are responsible for issueing the markers themselves.
80 if len(smooth_records) == 0: 80 if len(smooth_records) == 0:
81 if run_smooth_actions_record is None: 81 if run_smooth_actions_record is None:
82 sys.stderr.write('Raw tracing data:\n') 82 sys.stderr.write('Raw tracing data:\n')
83 sys.stderr.write(repr(self._tracing_timeline_data.EventData())) 83 sys.stderr.write(repr(self._tracing_timeline_data.EventData()))
84 sys.stderr.write('\n') 84 sys.stderr.write('\n')
85 raise Exception('SmoothnessController failed to issue markers for the ' 85 raise Exception('SmoothnessController failed to issue markers for the '
86 'whole interaction.') 86 'whole interaction.')
87 else: 87 else:
88 smooth_records = [run_smooth_actions_record] 88 smooth_records = [run_smooth_actions_record]
89 89
90 # Create an interaction_record for this legacy measurement. Since we don't 90 # Create an interaction_record for this legacy measurement. Since we don't
91 # wrap the results that is sent to smoothnes metric, the logical_name will 91 # wrap the results that is sent to smoothnes metric, the label will
92 # not be used. 92 # not be used.
93 smoothness_metric = smoothness.SmoothnessMetric() 93 smoothness_metric = smoothness.SmoothnessMetric()
94 smoothness_metric.AddResults( 94 smoothness_metric.AddResults(
95 self._timeline_model, renderer_thread, smooth_records, results) 95 self._timeline_model, renderer_thread, smooth_records, results)
96 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 96 if tab.browser.platform.IsRawDisplayFrameRateSupported():
97 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): 97 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
98 if r.value is None: 98 if r.value is None:
99 raise MissingDisplayFrameRateError(r.name) 99 raise MissingDisplayFrameRateError(r.name)
100 if isinstance(r.value, list): 100 if isinstance(r.value, list):
101 results.AddValue(list_of_scalar_values.ListOfScalarValues( 101 results.AddValue(list_of_scalar_values.ListOfScalarValues(
102 results.current_page, r.name, r.unit, r.value)) 102 results.current_page, r.name, r.unit, r.value))
103 else: 103 else:
104 results.AddValue(scalar.ScalarValue( 104 results.AddValue(scalar.ScalarValue(
105 results.current_page, r.name, r.unit, r.value)) 105 results.current_page, r.name, r.unit, r.value))
106 106
107 def CleanUp(self, tab): 107 def CleanUp(self, tab):
108 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 108 if tab.browser.platform.IsRawDisplayFrameRateSupported():
109 tab.browser.platform.StopRawDisplayFrameRateMeasurement() 109 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
110 if tab.browser.is_tracing_running: 110 if tab.browser.is_tracing_running:
111 tab.browser.StopTracing() 111 tab.browser.StopTracing()
OLDNEW
« no previous file with comments | « tools/perf/measurements/smooth_gesture_util.py ('k') | tools/perf/measurements/timeline_controller.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698