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

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

Issue 663023005: [Telemetry] Add file handle & trace value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready to land ^^ Created 6 years, 1 month 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.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.model import TimelineModel 9 from telemetry.timeline.model import TimelineModel
10 from telemetry.page import page_test 10 from telemetry.page import page_test
11 from telemetry.page.actions import action_runner 11 from telemetry.page.actions import action_runner
12 from telemetry.value import list_of_scalar_values 12 from telemetry.value import list_of_scalar_values
13 from telemetry.value import scalar 13 from telemetry.value import scalar
14 from telemetry.value import trace
14 from telemetry.web_perf import timeline_interaction_record as tir_module 15 from telemetry.web_perf import timeline_interaction_record as tir_module
15 from telemetry.web_perf.metrics import smoothness 16 from telemetry.web_perf.metrics import smoothness
16 17
17 18
18 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' 19 RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions'
19 20
20 # Descriptions for results from platform.GetRawDisplayFrameRateMeasurements(). 21 # Descriptions for results from platform.GetRawDisplayFrameRateMeasurements().
21 DESCRIPTIONS = { 22 DESCRIPTIONS = {
22 'avg_surface_fps': 'Average frames per second as measured by the ' 23 'avg_surface_fps': 'Average frames per second as measured by the '
23 'platform\'s SurfaceFlinger.' 24 'platform\'s SurfaceFlinger.'
(...skipping 25 matching lines...) Expand all
49 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 50 if tab.browser.platform.IsRawDisplayFrameRateSupported():
50 tab.browser.platform.StartRawDisplayFrameRateMeasurement() 51 tab.browser.platform.StartRawDisplayFrameRateMeasurement()
51 52
52 def Start(self, tab): 53 def Start(self, tab):
53 # Start the smooth marker for all smooth actions. 54 # Start the smooth marker for all smooth actions.
54 runner = action_runner.ActionRunner(tab) 55 runner = action_runner.ActionRunner(tab)
55 self._interaction = runner.BeginInteraction( 56 self._interaction = runner.BeginInteraction(
56 RUN_SMOOTH_ACTIONS, is_smooth=True) 57 RUN_SMOOTH_ACTIONS, is_smooth=True)
57 58
58 def Stop(self, tab): 59 def Stop(self, tab):
59 # End the smooth marker for all smooth actions. 60 # End the smooth marker for all smooth actions.
achuithb 2014/11/20 21:40:50 nit: remove extra space
60 self._interaction.End() 61 self._interaction.End()
61 # Stop tracing for smoothness metric. 62 # Stop tracing for smoothness metric.
62 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 63 if tab.browser.platform.IsRawDisplayFrameRateSupported():
63 tab.browser.platform.StopRawDisplayFrameRateMeasurement() 64 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
64 self._tracing_timeline_data = tab.browser.platform.tracing_controller.Stop() 65 self._tracing_timeline_data = tab.browser.platform.tracing_controller.Stop()
65 self._timeline_model = TimelineModel( 66 self._timeline_model = TimelineModel(
66 timeline_data=self._tracing_timeline_data) 67 timeline_data=self._tracing_timeline_data)
67 68
68 def AddResults(self, tab, results): 69 def AddResults(self, tab, results):
69 # Add results of smoothness metric. This computes the smoothness metric for 70 # Add results of smoothness metric. This computes the smoothness metric for
70 # the time ranges of gestures, if there is at least one, else the the time 71 # the time ranges of gestures, if there is at least one, else the the time
71 # ranges from the first action to the last action. 72 # ranges from the first action to the last action.
72 73 results.AddValue(trace.TraceValue(
74 results.current_page, self._tracing_timeline_data))
73 renderer_thread = self._timeline_model.GetRendererThreadFromTabId( 75 renderer_thread = self._timeline_model.GetRendererThreadFromTabId(
74 tab.id) 76 tab.id)
75 run_smooth_actions_record = None 77 run_smooth_actions_record = None
76 smooth_records = [] 78 smooth_records = []
77 for event in renderer_thread.async_slices: 79 for event in renderer_thread.async_slices:
78 if not tir_module.IsTimelineInteractionRecord(event.name): 80 if not tir_module.IsTimelineInteractionRecord(event.name):
79 continue 81 continue
80 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event) 82 r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
81 if r.label == RUN_SMOOTH_ACTIONS: 83 if r.label == RUN_SMOOTH_ACTIONS:
82 assert run_smooth_actions_record is None, ( 84 assert run_smooth_actions_record is None, (
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 else: 121 else:
120 results.AddValue(scalar.ScalarValue( 122 results.AddValue(scalar.ScalarValue(
121 results.current_page, r.name, r.unit, r.value, 123 results.current_page, r.name, r.unit, r.value,
122 description=DESCRIPTIONS.get(r.name))) 124 description=DESCRIPTIONS.get(r.name)))
123 125
124 def CleanUp(self, tab): 126 def CleanUp(self, tab):
125 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 127 if tab.browser.platform.IsRawDisplayFrameRateSupported():
126 tab.browser.platform.StopRawDisplayFrameRateMeasurement() 128 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
127 if tab.browser.platform.tracing_controller.is_tracing_running: 129 if tab.browser.platform.tracing_controller.is_tracing_running:
128 tab.browser.platform.tracing_controller.Stop() 130 tab.browser.platform.tracing_controller.Stop()
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/results/json_output_formatter.py » ('j') | tools/telemetry/telemetry/value/trace.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698