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

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

Issue 170183004: Move smoothness to the new API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit
Patch Set: Reset actions list. Modify repaint measurement. 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
« no previous file with comments | « tools/perf/measurements/smoothness.py ('k') | 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
(Empty)
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from metrics import smoothness
6 from metrics import timeline_interaction_record as tir_module
7 from telemetry.core.timeline.model import TimelineModel
8 from telemetry.page import page_measurement
9
10 import telemetry.core.timeline.bounds as timeline_bounds
11
12
13 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure):
14 def __init__(self, name):
15 super(MissingDisplayFrameRateError, self).__init__(
16 'Missing display frame rate metrics: ' + name)
17
18 class SmoothnessController(object):
19 def __init__(self):
20 self._actions = []
21 self._timeline_model = None
22
23 def Start(self, page, tab):
24 self._actions = []
25 custom_categories = ['webkit.console', 'benchmark']
26 custom_categories += page.GetSyntheticDelayCategories()
27 tab.browser.StartTracing(','.join(custom_categories), 60)
28 if tab.browser.platform.IsRawDisplayFrameRateSupported():
29 tab.browser.platform.StartRawDisplayFrameRateMeasurement()
30
31 def AddActionToIncludeInMetric(self, action):
32 self._actions.append(action)
33
34 def Stop(self, tab):
35 # Stop tracing for smoothness metric.
36 if tab.browser.platform.IsRawDisplayFrameRateSupported():
37 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
38 tracing_timeline_data = tab.browser.StopTracing()
39 self._timeline_model = TimelineModel(timeline_data=tracing_timeline_data)
40
41 def AddResults(self, tab, results):
42 # Add results of smoothness metric. This computes the smoothness metric for
43 # the time range between the first action starts and the last action ends.
44 # To get the measurement for each action, use
45 # measurement.TimelineBasedMeasurement.
46 time_bounds = timeline_bounds.Bounds()
47 for action in self._actions:
48 time_bounds.AddBounds(
49 action.GetActiveRangeOnTimeline(self._timeline_model))
50 # Create an interaction_record for this legacy measurement. Since we don't
51 # wrap the results that is sent to smoothnes metric, the logical_name will
52 # not be used.
53 interaction_record = tir_module.TimelineInteractionRecord(
54 'smoothness_interaction', time_bounds.min, time_bounds.max)
55 renderer_thread = self._timeline_model.GetRendererThreadFromTab(tab)
56 smoothness_metric = smoothness.SmoothnessMetric()
57 smoothness_metric.AddResults(self._timeline_model,
58 renderer_thread,
59 interaction_record,
60 results)
61 if tab.browser.platform.IsRawDisplayFrameRateSupported():
62 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
63 if r.value is None:
64 raise MissingDisplayFrameRateError(r.name)
65 results.Add(r.name, r.unit, r.value)
OLDNEW
« no previous file with comments | « tools/perf/measurements/smoothness.py ('k') | tools/perf/measurements/smoothness_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698