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

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

Issue 103143007: telemetry: Use trace categories to configure synthetic delays (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added scheduler benchmark and unittest. Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « tools/perf/benchmarks/smoothness.py ('k') | tools/perf/metrics/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
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 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 Metric 5 from metrics import Metric
6 from metrics import rendering_stats 6 from metrics import rendering_stats
7 from metrics import statistics 7 from metrics import statistics
8 from telemetry.page import page_measurement 8 from telemetry.page import page_measurement
9 9
10 TIMELINE_MARKER = 'Smoothness' 10 TIMELINE_MARKER = 'Smoothness'
11 11
12 12
13 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): 13 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure):
14 def __init__(self, name): 14 def __init__(self, name):
15 super(MissingDisplayFrameRateError, self).__init__( 15 super(MissingDisplayFrameRateError, self).__init__(
16 'Missing display frame rate metrics: ' + name) 16 'Missing display frame rate metrics: ' + name)
17 17
18 class NotEnoughFramesError(page_measurement.MeasurementFailure): 18 class NotEnoughFramesError(page_measurement.MeasurementFailure):
19 def __init__(self): 19 def __init__(self):
20 super(NotEnoughFramesError, self).__init__( 20 super(NotEnoughFramesError, self).__init__(
21 'Page output less than two frames') 21 'Page output less than two frames')
22 22
23 23
24 class NoSupportedActionError(page_measurement.MeasurementFailure): 24 class NoSupportedActionError(page_measurement.MeasurementFailure):
25 def __init__(self): 25 def __init__(self):
26 super(NoSupportedActionError, self).__init__( 26 super(NoSupportedActionError, self).__init__(
27 'None of the actions is supported by smoothness measurement') 27 'None of the actions is supported by smoothness measurement')
28 28
29 29
30 def _GetSyntheticDelayCategoriesFromPage(page):
31 if not hasattr(page, 'synthetic_delays'):
32 return []
33 result = []
34 for delay, options in page.synthetic_delays.items():
35 options = '%f;%s' % (options.get('target_duration', 0),
36 options.get('mode', 'static'))
37 result.append('DELAY(%s;%s)' % (delay, options))
38 return result
39
40
30 class SmoothnessMetric(Metric): 41 class SmoothnessMetric(Metric):
31 def __init__(self): 42 def __init__(self):
32 super(SmoothnessMetric, self).__init__() 43 super(SmoothnessMetric, self).__init__()
33 self._stats = None 44 self._stats = None
34 self._actions = [] 45 self._actions = []
35 46
36 def AddActionToIncludeInMetric(self, action): 47 def AddActionToIncludeInMetric(self, action):
37 self._actions.append(action) 48 self._actions.append(action)
38 49
39 def Start(self, page, tab): 50 def Start(self, page, tab):
40 tab.browser.StartTracing('webkit.console,benchmark', 60) 51 custom_categories = ['webkit.console', 'benchmark']
52 custom_categories += _GetSyntheticDelayCategoriesFromPage(page)
53 tab.browser.StartTracing(','.join(custom_categories), 60)
41 tab.ExecuteJavaScript('console.time("' + TIMELINE_MARKER + '")') 54 tab.ExecuteJavaScript('console.time("' + TIMELINE_MARKER + '")')
42 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 55 if tab.browser.platform.IsRawDisplayFrameRateSupported():
43 tab.browser.platform.StartRawDisplayFrameRateMeasurement() 56 tab.browser.platform.StartRawDisplayFrameRateMeasurement()
44 57
45 def Stop(self, page, tab): 58 def Stop(self, page, tab):
46 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 59 if tab.browser.platform.IsRawDisplayFrameRateSupported():
47 tab.browser.platform.StopRawDisplayFrameRateMeasurement() 60 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
48 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")') 61 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")')
49 timeline_model = tab.browser.StopTracing().AsTimelineModel() 62 timeline_model = tab.browser.StopTracing().AsTimelineModel()
50 timeline_ranges = [ action.GetActiveRangeOnTimeline(timeline_model) 63 timeline_ranges = [ action.GetActiveRangeOnTimeline(timeline_model)
(...skipping 28 matching lines...) Expand all
79 # Are we hitting 60 fps for 95 percent of all frames? 92 # Are we hitting 60 fps for 95 percent of all frames?
80 # We use 19ms as a somewhat looser threshold, instead of 1000.0/60.0. 93 # We use 19ms as a somewhat looser threshold, instead of 1000.0/60.0.
81 percentile_95 = statistics.Percentile(self._stats.frame_times, 95.0) 94 percentile_95 = statistics.Percentile(self._stats.frame_times, 95.0)
82 results.Add('mostly_smooth', '', 1.0 if percentile_95 < 19.0 else 0.0) 95 results.Add('mostly_smooth', '', 1.0 if percentile_95 < 19.0 else 0.0)
83 96
84 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 97 if tab.browser.platform.IsRawDisplayFrameRateSupported():
85 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): 98 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
86 if r.value is None: 99 if r.value is None:
87 raise MissingDisplayFrameRateError(r.name) 100 raise MissingDisplayFrameRateError(r.name)
88 results.Add(r.name, r.unit, r.value) 101 results.Add(r.name, r.unit, r.value)
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/smoothness.py ('k') | tools/perf/metrics/smoothness_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698