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

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

Issue 29423005: telemetry: Add GetRendererProcessFromTab to timeline model. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix smoothness_unittest.py. Created 7 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 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
nduca 2013/10/31 07:32:02 i'm pretty sure there are other uses in perf/ that
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.core.timeline.model import MarkerMismatchError 8 from telemetry.core.timeline.model import MarkerMismatchError
9 from telemetry.core.timeline.model import MarkerOverlapError 9 from telemetry.core.timeline.model import MarkerOverlapError
10 from telemetry.page import page_measurement 10 from telemetry.page import page_measurement
11 11
12 TIMELINE_MARKER = 'SmoothnessMetric' 12 TIMELINE_MARKER = 'Smoothness'
13 13
14 14
15 class NotEnoughFramesError(page_measurement.MeasurementFailure): 15 class NotEnoughFramesError(page_measurement.MeasurementFailure):
16 def __init__(self): 16 def __init__(self):
17 super(NotEnoughFramesError, self).__init__( 17 super(NotEnoughFramesError, self).__init__(
18 'Page output less than two frames') 18 'Page output less than two frames')
19 19
20 20
21 class NoSupportedActionError(page_measurement.MeasurementFailure): 21 class NoSupportedActionError(page_measurement.MeasurementFailure):
22 def __init__(self): 22 def __init__(self):
(...skipping 21 matching lines...) Expand all
44 44
45 def Start(self, page, tab): 45 def Start(self, page, tab):
46 # TODO(ermst): Remove "webkit" category after Blink r157377 is picked up by 46 # TODO(ermst): Remove "webkit" category after Blink r157377 is picked up by
47 # the reference builds. 47 # the reference builds.
48 tab.browser.StartTracing('webkit,webkit.console,benchmark', 60) 48 tab.browser.StartTracing('webkit,webkit.console,benchmark', 60)
49 tab.ExecuteJavaScript('console.time("' + TIMELINE_MARKER + '")') 49 tab.ExecuteJavaScript('console.time("' + TIMELINE_MARKER + '")')
50 50
51 def Stop(self, page, tab): 51 def Stop(self, page, tab):
52 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")') 52 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")')
53 timeline_model = tab.browser.StopTracing().AsTimelineModel() 53 timeline_model = tab.browser.StopTracing().AsTimelineModel()
54 render_process_marker = timeline_model.FindTimelineMarkers(TIMELINE_MARKER) 54 smoothness_marker = timeline_model.FindTimelineMarkers(TIMELINE_MARKER)
55 timeline_marker_labels = GetTimelineMarkerLabelsFromAction( 55 timeline_marker_labels = GetTimelineMarkerLabelsFromAction(
nduca 2013/10/31 07:32:02 Labels is a bit funky. TimelineEvents have names,
ernstm 2013/11/05 00:25:05 Done.
56 self._compound_action) 56 self._compound_action)
57 try: 57 try:
58 timeline_markers = timeline_model.FindTimelineMarkers( 58 timeline_markers = timeline_model.FindTimelineMarkers(
59 timeline_marker_labels) 59 timeline_marker_labels)
60 except MarkerMismatchError: 60 except MarkerMismatchError:
61 # TODO(ernstm): re-raise exception as MeasurementFailure when the 61 # TODO(ernstm): re-raise exception as MeasurementFailure when the
62 # reference build was updated. 62 # reference build was updated.
63 timeline_markers = render_process_marker 63 timeline_markers = smoothness_marker
64 except MarkerOverlapError as e: 64 except MarkerOverlapError as e:
65 raise page_measurement.MeasurementFailure(str(e)) 65 raise page_measurement.MeasurementFailure(str(e))
66 66
67 renderer_process = timeline_model.GetRendererProcessFromTab(tab)
67 self._stats = rendering_stats.RenderingStats( 68 self._stats = rendering_stats.RenderingStats(
68 render_process_marker, timeline_markers) 69 renderer_process, timeline_markers)
69 70
70 if not self._stats.frame_times: 71 if not self._stats.frame_times:
71 raise NotEnoughFramesError() 72 raise NotEnoughFramesError()
72 73
74 def SetStats(self, stats):
nduca 2013/10/31 07:32:02 This isn't quite the right direction to be pursuin
ernstm 2013/11/05 00:25:05 I agree that smoothness_unittest.py needs a major
75 """ Pass in a RenderingStats object directly. For unittests that don't call
76 Start/Stop.
77 """
78 self._stats = stats
73 79
74 def AddResults(self, tab, results): 80 def AddResults(self, tab, results):
75 # List of raw frame times. 81 # List of raw frame times.
76 results.Add('frame_times', 'ms', self._stats.frame_times) 82 results.Add('frame_times', 'ms', self._stats.frame_times)
77 83
78 # Arithmetic mean of frame times. 84 # Arithmetic mean of frame times.
79 mean_frame_time = statistics.ArithmeticMean(self._stats.frame_times, 85 mean_frame_time = statistics.ArithmeticMean(self._stats.frame_times,
80 len(self._stats.frame_times)) 86 len(self._stats.frame_times))
81 results.Add('mean_frame_time', 'ms', round(mean_frame_time, 3)) 87 results.Add('mean_frame_time', 'ms', round(mean_frame_time, 3))
82 88
83 # Absolute discrepancy of frame time stamps. 89 # Absolute discrepancy of frame time stamps.
84 jank = statistics.FrameDiscrepancy(self._stats.frame_timestamps) 90 jank = statistics.FrameDiscrepancy(self._stats.frame_timestamps)
85 results.Add('jank', '', round(jank, 4)) 91 results.Add('jank', '', round(jank, 4))
86 92
87 # Are we hitting 60 fps for 95 percent of all frames? (Boolean value) 93 # Are we hitting 60 fps for 95 percent of all frames? (Boolean value)
88 # We use 17ms as a slightly looser threshold, instead of 1000.0/60.0. 94 # We use 17ms as a slightly looser threshold, instead of 1000.0/60.0.
89 results.Add('mostly_smooth', '', 95 results.Add('mostly_smooth', '',
90 statistics.Percentile(self._stats.frame_times, 95.0) < 17.0) 96 statistics.Percentile(self._stats.frame_times, 95.0) < 17.0)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698