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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 tab.browser.platform.StartRawDisplayFrameRateMeasurement() | 43 tab.browser.platform.StartRawDisplayFrameRateMeasurement() |
| 44 | 44 |
| 45 def Stop(self, page, tab): | 45 def Stop(self, page, tab): |
| 46 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 46 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 47 tab.browser.platform.StopRawDisplayFrameRateMeasurement() | 47 tab.browser.platform.StopRawDisplayFrameRateMeasurement() |
| 48 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")') | 48 tab.ExecuteJavaScript('console.timeEnd("' + TIMELINE_MARKER + '")') |
| 49 timeline_model = tab.browser.StopTracing().AsTimelineModel() | 49 timeline_model = tab.browser.StopTracing().AsTimelineModel() |
| 50 timeline_ranges = [ action.GetActiveRangeOnTimeline(timeline_model) | 50 timeline_ranges = [ action.GetActiveRangeOnTimeline(timeline_model) |
| 51 for action in self._actions ] | 51 for action in self._actions ] |
| 52 | 52 |
| 53 browser_process = timeline_model.GetProcess(tab.browser.browser_pid) | |
| 53 renderer_process = timeline_model.GetRendererProcessFromTab(tab) | 54 renderer_process = timeline_model.GetRendererProcessFromTab(tab) |
| 54 self._stats = rendering_stats.RenderingStats( | 55 self._stats = rendering_stats.RenderingStats( |
| 55 renderer_process, timeline_ranges) | 56 renderer_process, browser_process, timeline_ranges) |
| 56 | 57 |
| 57 if not self._stats.frame_times: | 58 if not self._stats.frame_times: |
| 58 raise NotEnoughFramesError() | 59 raise NotEnoughFramesError() |
| 59 | 60 |
| 60 def SetStats(self, stats): | 61 def SetStats(self, stats): |
| 61 """ Pass in a RenderingStats object directly. For unittests that don't call | 62 """ Pass in a RenderingStats object directly. For unittests that don't call |
| 62 Start/Stop. | 63 Start/Stop. |
| 63 """ | 64 """ |
| 64 self._stats = stats | 65 self._stats = stats |
| 65 | 66 |
| 66 def AddResults(self, tab, results): | 67 def AddResults(self, tab, results): |
|
nduca
2014/01/13 18:49:32
needs unit tests
Yufeng Shen (Slow to review)
2014/01/14 00:05:47
I assume the unittests for this is a test that sta
Yufeng Shen (Slow to review)
2014/01/20 21:59:30
Test added.
| |
| 68 if self._stats.mouse_wheel_latency: | |
| 69 mean_mouse_wheel_latency = statistics.ArithmeticMean( | |
| 70 self._stats.mouse_wheel_latency, len(self._stats.mouse_wheel_latency)) | |
| 71 results.Add('mean_mouse_wheel_latency', 'ms', | |
| 72 round(mean_mouse_wheel_latency, 3)) | |
| 73 results.Add('mouse_wheel_latency_75%', 'ms', | |
| 74 statistics.Percentile(self._stats.mouse_wheel_latency, 75.0) ) | |
| 75 | |
| 76 if self._stats.gesture_scroll_latency: | |
| 77 mean_gesture_scroll_latency = statistics.ArithmeticMean( | |
| 78 self._stats.gesture_scroll_latency, | |
| 79 len(self._stats.gesture_scroll_latency)) | |
| 80 results.Add('mean_gesture_scroll_latency', 'ms', | |
| 81 round(mean_gesture_scroll_latency, 3)) | |
| 82 results.Add('gesture_scroll_latency_75%', 'ms', | |
| 83 statistics.Percentile(self._stats.gesture_scroll_latency, | |
| 84 75.0) ) | |
| 85 | |
| 86 if self._stats.touch_scroll_latency: | |
| 87 mean_touch_scroll_latency = statistics.ArithmeticMean( | |
| 88 self._stats.touch_scroll_latency, | |
| 89 len(self._stats.touch_scroll_latency)) | |
| 90 results.Add('mean_touch_scroll_latency', 'ms', | |
| 91 round(mean_touch_scroll_latency, 3)) | |
| 92 results.Add('touch_scroll_latency_75%', 'ms', | |
| 93 statistics.Percentile(self._stats.touch_scroll_latency, | |
| 94 75.0) ) | |
| 67 # List of raw frame times. | 95 # List of raw frame times. |
| 68 results.Add('frame_times', 'ms', self._stats.frame_times) | 96 results.Add('frame_times', 'ms', self._stats.frame_times) |
| 69 | 97 |
| 70 # Arithmetic mean of frame times. | 98 # Arithmetic mean of frame times. |
| 71 mean_frame_time = statistics.ArithmeticMean(self._stats.frame_times, | 99 mean_frame_time = statistics.ArithmeticMean(self._stats.frame_times, |
| 72 len(self._stats.frame_times)) | 100 len(self._stats.frame_times)) |
| 73 results.Add('mean_frame_time', 'ms', round(mean_frame_time, 3)) | 101 results.Add('mean_frame_time', 'ms', round(mean_frame_time, 3)) |
| 74 | 102 |
| 75 # Absolute discrepancy of frame time stamps. | 103 # Absolute discrepancy of frame time stamps. |
| 76 jank = statistics.FrameDiscrepancy(self._stats.frame_timestamps) | 104 jank = statistics.FrameDiscrepancy(self._stats.frame_timestamps) |
| 77 results.Add('jank', '', round(jank, 4)) | 105 results.Add('jank', '', round(jank, 4)) |
| 78 | 106 |
| 79 # Are we hitting 60 fps for 95 percent of all frames? | 107 # 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. | 108 # 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) | 109 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) | 110 results.Add('mostly_smooth', '', 1.0 if percentile_95 < 19.0 else 0.0) |
| 83 | 111 |
| 84 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 112 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 85 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): | 113 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): |
| 86 if r.value is None: | 114 if r.value is None: |
| 87 raise MissingDisplayFrameRateError(r.name) | 115 raise MissingDisplayFrameRateError(r.name) |
| 88 results.Add(r.name, r.unit, r.value) | 116 results.Add(r.name, r.unit, r.value) |
| OLD | NEW |