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

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

Issue 170183004: Move smoothness to the new API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit
Patch Set: Created 6 years, 9 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 (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 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 from metrics import power 5 from metrics import power
6 from metrics import smoothness 6 from metrics import smoothness
7 from metrics import timeline_interaction_record as tir_module
8 from telemetry.core.timeline.model import TimelineModel
7 from telemetry.page import page_measurement 9 from telemetry.page import page_measurement
8 10
11 import telemetry.core.timeline.bounds as timeline_bounds
12
13
14 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure):
15 def __init__(self, name):
16 super(MissingDisplayFrameRateError, self).__init__(
17 'Missing display frame rate metrics: ' + name)
18
19
20 def _GetSyntheticDelayCategoriesFromPage(page):
nduca 2014/03/07 20:05:56 Lets put this code somewhere common. Maybe we pass
21 if not hasattr(page, 'synthetic_delays'):
22 return []
23 result = []
24 for delay, options in page.synthetic_delays.items():
25 options = '%f;%s' % (options.get('target_duration', 0),
26 options.get('mode', 'static'))
27 result.append('DELAY(%s;%s)' % (delay, options))
28 return result
9 29
10 class Smoothness(page_measurement.PageMeasurement): 30 class Smoothness(page_measurement.PageMeasurement):
11 def __init__(self): 31 def __init__(self):
12 super(Smoothness, self).__init__('smoothness') 32 super(Smoothness, self).__init__('smoothness')
13 self._smoothness_metric = None 33 self._smoothness_metric = None
14 self._power_metric = None 34 self._power_metric = None
35 self._timeline_model = None
36 self._actions = []
15 37
16 def CustomizeBrowserOptions(self, options): 38 def CustomizeBrowserOptions(self, options):
17 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') 39 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking')
18 power.PowerMetric.CustomizeBrowserOptions(options) 40 power.PowerMetric.CustomizeBrowserOptions(options)
19 41
20 def CanRunForPage(self, page): 42 def CanRunForPage(self, page):
21 return hasattr(page, 'smoothness') 43 return hasattr(page, 'smoothness')
22 44
23 def WillRunActions(self, page, tab): 45 def WillRunActions(self, page, tab):
24 self._power_metric = power.PowerMetric() 46 self._power_metric = power.PowerMetric()
25 self._power_metric.Start(page, tab) 47 self._power_metric.Start(page, tab)
26 self._smoothness_metric = smoothness.SmoothnessMetric() 48 self._smoothness_metric = smoothness.SmoothnessMetric()
27 self._smoothness_metric.Start(page, tab) 49 # Start tracing for smoothness metric
nduca 2014/03/07 20:05:56 end with period.
50 custom_categories = ['webkit.console', 'benchmark']
51 custom_categories += _GetSyntheticDelayCategoriesFromPage(page)
52 tab.browser.StartTracing(','.join(custom_categories), 60)
53 if tab.browser.platform.IsRawDisplayFrameRateSupported():
54 tab.browser.platform.StartRawDisplayFrameRateMeasurement()
28 55
29 def DidRunAction(self, page, tab, action): 56 def DidRunAction(self, page, tab, action):
30 self._smoothness_metric.AddActionToIncludeInMetric(action) 57 self._actions.append(action)
31 58
32 def DidRunActions(self, page, tab): 59 def DidRunActions(self, page, tab):
33 self._power_metric.Stop(page, tab) 60 self._power_metric.Stop(page, tab)
34 self._smoothness_metric.Stop(page, tab) 61 # Stop tracing for smoothness metric
62 if tab.browser.platform.IsRawDisplayFrameRateSupported():
63 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
64 tracing_timeline_data = tab.browser.StopTracing()
65 self._timeline_model = TimelineModel(timeline_data=tracing_timeline_data)
35 66
36 def MeasurePage(self, page, tab, results): 67 def MeasurePage(self, page, tab, results):
37 self._power_metric.AddResults(tab, results) 68 self._power_metric.AddResults(tab, results)
38 self._smoothness_metric.AddResults(tab, results) 69 # Add results of smoothness metric. This computes the smoothness metric for
70 # the time range between the first action starts and the last action ends.
71 # To get the measurement for each action, use
72 # measurement.TimelineBasedMeasurement.
73 time_bounds = timeline_bounds.Bounds()
74 for action in self._actions:
75 time_bounds.AddBounds(
76 action.GetActiveRangeOnTimeline(self._timeline_model))
77 interaction_record = tir_module.TimelineInteractionRecord.\
78 FromBounds(time_bounds)
79 renderer_thread = self._timeline_model.GetRendererThreadFromTab(tab)
80 self._smoothness_metric.AddResults(self._timeline_model,
81 renderer_thread,
82 interaction_record,
83 results)
84 if tab.browser.platform.IsRawDisplayFrameRateSupported():
85 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
86 if r.value is None:
87 raise MissingDisplayFrameRateError(r.name)
88 results.Add(r.name, r.unit, r.value)
OLDNEW
« no previous file with comments | « no previous file | tools/perf/measurements/smoothness_unittest.py » ('j') | tools/perf/metrics/timeline_based_metric.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698