Chromium Code Reviews| OLD | NEW |
|---|---|
| 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' |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 | 57 |
| 58 def Stop(self, page, tab): | 58 def Stop(self, page, tab): |
| 59 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 59 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 60 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 60 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
| 61 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")') | 61 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")') |
| 62 timeline_model = tab.browser.StopTracing().AsTimelineModel() | 62 timeline_model = tab.browser.StopTracing().AsTimelineModel() |
| 63 timeline_ranges = [ action.GetActiveRangeOnTimeline(timeline_model) | 63 timeline_ranges = [ action.GetActiveRangeOnTimeline(timeline_model) |
| 64 for action in self._actions ] | 64 for action in self._actions ] |
| 65 | 65 |
| 66 renderer_process = timeline_model.GetRendererProcessFromTab(tab) | 66 renderer_process = timeline_model.GetRendererProcessFromTab(tab) |
| 67 browser_main_thread = timeline_model.GetBrowserMainThread() | |
| 68 | |
| 67 self._stats = rendering_stats.RenderingStats( | 69 self._stats = rendering_stats.RenderingStats( |
| 68 renderer_process, timeline_ranges) | 70 renderer_process, browser_main_thread, timeline_ranges) |
| 69 | 71 |
| 70 if not self._stats.frame_times: | 72 if not self._stats.frame_times: |
| 71 raise NotEnoughFramesError() | 73 raise NotEnoughFramesError() |
| 72 | 74 |
| 73 def SetStats(self, stats): | 75 def SetStats(self, stats): |
| 74 """ Pass in a RenderingStats object directly. For unittests that don't call | 76 """ Pass in a RenderingStats object directly. For unittests that don't call |
| 75 Start/Stop. | 77 Start/Stop. |
| 76 """ | 78 """ |
| 77 self._stats = stats | 79 self._stats = stats |
| 78 | 80 |
| 79 def AddResults(self, tab, results): | 81 def AddResults(self, tab, results): |
| 82 if self._stats.mouse_wheel_latency: | |
| 83 mean_mouse_wheel_latency = statistics.ArithmeticMean( | |
| 84 self._stats.mouse_wheel_latency, len(self._stats.mouse_wheel_latency)) | |
| 85 results.Add('mean_mouse_wheel_latency', 'ms', | |
| 86 round(mean_mouse_wheel_latency, 3)) | |
| 87 results.Add('mouse_wheel_latency_75%', 'ms', | |
| 88 statistics.Percentile(self._stats.mouse_wheel_latency, 75.0) ) | |
| 89 | |
| 90 if self._stats.gesture_scroll_latency: | |
| 91 mean_gesture_scroll_latency = statistics.ArithmeticMean( | |
| 92 self._stats.gesture_scroll_latency, | |
| 93 len(self._stats.gesture_scroll_latency)) | |
| 94 results.Add('mean_gesture_scroll_latency', 'ms', | |
| 95 round(mean_gesture_scroll_latency, 3)) | |
| 96 results.Add('gesture_scroll_latency_75%', 'ms', | |
|
Rick Byers
2014/01/21 13:57:17
Has there been any discussion of what the right me
Yufeng Shen (Slow to review)
2014/01/22 23:23:35
Done.
Rick Byers
2014/01/23 00:57:05
Thanks. How consistent does this tend to be from
| |
| 97 statistics.Percentile(self._stats.gesture_scroll_latency, | |
| 98 75.0) ) | |
| 99 | |
| 100 if self._stats.touch_scroll_latency: | |
| 101 mean_touch_scroll_latency = statistics.ArithmeticMean( | |
| 102 self._stats.touch_scroll_latency, | |
| 103 len(self._stats.touch_scroll_latency)) | |
| 104 results.Add('mean_touch_scroll_latency', 'ms', | |
| 105 round(mean_touch_scroll_latency, 3)) | |
| 106 results.Add('touch_scroll_latency_75%', 'ms', | |
| 107 statistics.Percentile(self._stats.touch_scroll_latency, | |
| 108 75.0) ) | |
| 80 # List of raw frame times. | 109 # List of raw frame times. |
| 81 results.Add('frame_times', 'ms', self._stats.frame_times) | 110 results.Add('frame_times', 'ms', self._stats.frame_times) |
| 82 | 111 |
| 83 # Arithmetic mean of frame times. | 112 # Arithmetic mean of frame times. |
| 84 mean_frame_time = statistics.ArithmeticMean(self._stats.frame_times, | 113 mean_frame_time = statistics.ArithmeticMean(self._stats.frame_times, |
| 85 len(self._stats.frame_times)) | 114 len(self._stats.frame_times)) |
| 86 results.Add('mean_frame_time', 'ms', round(mean_frame_time, 3)) | 115 results.Add('mean_frame_time', 'ms', round(mean_frame_time, 3)) |
| 87 | 116 |
| 88 # Absolute discrepancy of frame time stamps. | 117 # Absolute discrepancy of frame time stamps. |
| 89 jank = statistics.FrameDiscrepancy(self._stats.frame_timestamps) | 118 jank = statistics.FrameDiscrepancy(self._stats.frame_timestamps) |
| 90 results.Add('jank', '', round(jank, 4)) | 119 results.Add('jank', '', round(jank, 4)) |
| 91 | 120 |
| 92 # Are we hitting 60 fps for 95 percent of all frames? | 121 # Are we hitting 60 fps for 95 percent of all frames? |
| 93 # We use 19ms as a somewhat looser threshold, instead of 1000.0/60.0. | 122 # We use 19ms as a somewhat looser threshold, instead of 1000.0/60.0. |
| 94 percentile_95 = statistics.Percentile(self._stats.frame_times, 95.0) | 123 percentile_95 = statistics.Percentile(self._stats.frame_times, 95.0) |
| 95 results.Add('mostly_smooth', 'score', 1.0 if percentile_95 < 19.0 else 0.0) | 124 results.Add('mostly_smooth', 'score', 1.0 if percentile_95 < 19.0 else 0.0) |
| 96 | 125 |
| 97 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 126 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 98 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): | 127 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): |
| 99 if r.value is None: | 128 if r.value is None: |
| 100 raise MissingDisplayFrameRateError(r.name) | 129 raise MissingDisplayFrameRateError(r.name) |
| 101 results.Add(r.name, r.unit, r.value) | 130 results.Add(r.name, r.unit, r.value) |
| OLD | NEW |