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

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

Issue 23902027: telemetry: Make trace profiler work with trace-based benchmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tracking nesting calls on Start/StopTracing. Created 7 years, 3 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 from metrics import loading 4 from metrics import loading
5 from metrics import smoothness 5 from metrics import smoothness
6 from metrics.gpu_rendering_stats import GpuRenderingStats 6 from metrics.gpu_rendering_stats import GpuRenderingStats
7 from telemetry.page import page_measurement 7 from telemetry.page import page_measurement
8 8
9 9
10 class DidNotScrollException(page_measurement.MeasurementFailure): 10 class DidNotScrollException(page_measurement.MeasurementFailure):
(...skipping 10 matching lines...) Expand all
21 class MissingTimelineMarker(page_measurement.MeasurementFailure): 21 class MissingTimelineMarker(page_measurement.MeasurementFailure):
22 def __init__(self): 22 def __init__(self):
23 super(MissingTimelineMarker, self).__init__('Timeline marker not found') 23 super(MissingTimelineMarker, self).__init__('Timeline marker not found')
24 24
25 25
26 class Smoothness(page_measurement.PageMeasurement): 26 class Smoothness(page_measurement.PageMeasurement):
27 def __init__(self): 27 def __init__(self):
28 super(Smoothness, self).__init__('smoothness') 28 super(Smoothness, self).__init__('smoothness')
29 self.force_enable_threaded_compositing = False 29 self.force_enable_threaded_compositing = False
30 self._metrics = None 30 self._metrics = None
31 self._timeline = None
31 32
32 def AddCommandLineOptions(self, parser): 33 def AddCommandLineOptions(self, parser):
33 parser.add_option('--report-all-results', dest='report_all_results', 34 parser.add_option('--report-all-results', dest='report_all_results',
34 action='store_true', 35 action='store_true',
35 help='Reports all data collected, not just FPS') 36 help='Reports all data collected, not just FPS')
36 37
37 def CustomizeBrowserOptions(self, options): 38 def CustomizeBrowserOptions(self, options):
38 smoothness.SmoothnessMetrics.CustomizeBrowserOptions(options) 39 smoothness.SmoothnessMetrics.CustomizeBrowserOptions(options)
39 if self.force_enable_threaded_compositing: 40 if self.force_enable_threaded_compositing:
40 options.AppendExtraBrowserArgs('--enable-threaded-compositing') 41 options.AppendExtraBrowserArgs('--enable-threaded-compositing')
41 42
42 def CanRunForPage(self, page): 43 def CanRunForPage(self, page):
43 return hasattr(page, 'smoothness') 44 return hasattr(page, 'smoothness')
44 45
45 def WillRunAction(self, page, tab, action): 46 def WillRunAction(self, page, tab, action):
46 # TODO(ernstm): remove 'webkit' category when 47 tab.browser.StartTracing('webkit.console,benchmark', 60)
47 # https://codereview.chromium.org/23848006/ has landed.
48 tab.browser.StartTracing('webkit,webkit.console,benchmark', 60)
49 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 48 if tab.browser.platform.IsRawDisplayFrameRateSupported():
50 tab.browser.platform.StartRawDisplayFrameRateMeasurement() 49 tab.browser.platform.StartRawDisplayFrameRateMeasurement()
51 self._metrics = smoothness.SmoothnessMetrics(tab) 50 self._metrics = smoothness.SmoothnessMetrics(tab)
52 if action.CanBeBound(): 51 if action.CanBeBound():
53 self._metrics.BindToAction(action) 52 self._metrics.BindToAction(action)
54 else: 53 else:
55 self._metrics.Start() 54 self._metrics.Start()
56 55
57 def DidRunAction(self, page, tab, action): 56 def DidRunAction(self, page, tab, action):
58 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 57 if tab.browser.platform.IsRawDisplayFrameRateSupported():
59 tab.browser.platform.StopRawDisplayFrameRateMeasurement() 58 tab.browser.platform.StopRawDisplayFrameRateMeasurement()
60 if not action.CanBeBound(): 59 if not action.CanBeBound():
61 self._metrics.Stop() 60 self._metrics.Stop()
62 tab.browser.StopTracing() 61 self._timeline = tab.browser.StopTracing().AsTimelineModel()
tonyg 2013/09/12 00:49:55 Same question about whether we should do the AsTim
ernstm 2013/09/12 18:06:07 Done.
63 62
64 def FindTimelineMarker(self, timeline): 63 def FindTimelineMarker(self, timeline):
65 events = [s for 64 events = [s for
66 s in timeline.GetAllEventsOfName( 65 s in timeline.GetAllEventsOfName(
67 smoothness.TIMELINE_MARKER) 66 smoothness.TIMELINE_MARKER)
68 if s.parent_slice == None] 67 if s.parent_slice == None]
69 if len(events) != 1: 68 if len(events) != 1:
70 raise MissingTimelineMarker() 69 raise MissingTimelineMarker()
71 return events[0] 70 return events[0]
72 71
73 def MeasurePage(self, page, tab, results): 72 def MeasurePage(self, page, tab, results):
74 rendering_stats_deltas = self._metrics.deltas 73 rendering_stats_deltas = self._metrics.deltas
75 74
76 if not (rendering_stats_deltas['numFramesSentToScreen'] > 0): 75 if not (rendering_stats_deltas['numFramesSentToScreen'] > 0):
77 raise DidNotScrollException() 76 raise DidNotScrollException()
78 77
79 loading.LoadingMetric().AddResults(tab, results) 78 loading.LoadingMetric().AddResults(tab, results)
80 79
81 smoothness.CalcFirstPaintTimeResults(results, tab) 80 smoothness.CalcFirstPaintTimeResults(results, tab)
82 81
83 timeline = tab.browser.GetTraceResultAndReset().AsTimelineModel() 82 timeline_marker = self.FindTimelineMarker(self._timeline)
84 timeline_marker = self.FindTimelineMarker(timeline)
85 benchmark_stats = GpuRenderingStats(timeline_marker, 83 benchmark_stats = GpuRenderingStats(timeline_marker,
86 rendering_stats_deltas, 84 rendering_stats_deltas,
87 self._metrics.is_using_gpu_benchmarking) 85 self._metrics.is_using_gpu_benchmarking)
88 smoothness.CalcResults(benchmark_stats, results) 86 smoothness.CalcResults(benchmark_stats, results)
89 87
90 if self.options.report_all_results: 88 if self.options.report_all_results:
91 for k, v in rendering_stats_deltas.iteritems(): 89 for k, v in rendering_stats_deltas.iteritems():
92 results.Add(k, '', v) 90 results.Add(k, '', v)
93 91
94 if tab.browser.platform.IsRawDisplayFrameRateSupported(): 92 if tab.browser.platform.IsRawDisplayFrameRateSupported():
95 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): 93 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
96 if r.value is None: 94 if r.value is None:
97 raise MissingDisplayFrameRate(r.name) 95 raise MissingDisplayFrameRate(r.name)
98 results.Add(r.name, r.unit, r.value) 96 results.Add(r.name, r.unit, r.value)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698