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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * @fileoverview This file provides the RenderingStats object, used | 8 * @fileoverview This file provides the RenderingStats object, used |
9 * to characterize rendering smoothness. | 9 * to characterize rendering smoothness. |
10 */ | 10 */ |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 RafRenderingStats.prototype.recordFrameTime_ = function(timestamp) { | 142 RafRenderingStats.prototype.recordFrameTime_ = function(timestamp) { |
143 if (!this.recording_) | 143 if (!this.recording_) |
144 return; | 144 return; |
145 | 145 |
146 this.frameTimes_.push(timestamp); | 146 this.frameTimes_.push(timestamp); |
147 requestAnimationFrame(this.recordFrameTime_.bind(this)); | 147 requestAnimationFrame(this.recordFrameTime_.bind(this)); |
148 }; | 148 }; |
149 | 149 |
150 RafRenderingStats.prototype.getDroppedFrameCount_ = function(frameTimes) { | 150 RafRenderingStats.prototype.getDroppedFrameCount_ = function(frameTimes) { |
151 var droppedFrameCount = 0; | 151 var droppedFrameCount = 0; |
| 152 var droppedFrameThreshold = 1000 / 55; |
152 for (var i = 1; i < frameTimes.length; i++) { | 153 for (var i = 1; i < frameTimes.length; i++) { |
153 var frameTime = frameTimes[i] - frameTimes[i-1]; | 154 var frameTime = frameTimes[i] - frameTimes[i-1]; |
154 if (frameTime > 1000 / 55) | 155 if (frameTime > droppedFrameThreshold) |
155 droppedFrameCount++; | 156 droppedFrameCount += Math.floor(frameTime / droppedFrameThreshold); |
156 } | 157 } |
157 return droppedFrameCount; | 158 return droppedFrameCount; |
158 }; | 159 }; |
159 | 160 |
160 function RenderingStats() { | 161 function RenderingStats() { |
161 if (window.chrome && chrome.gpuBenchmarking && | 162 if (window.chrome && chrome.gpuBenchmarking && |
162 chrome.gpuBenchmarking.renderingStats) { | 163 chrome.gpuBenchmarking.renderingStats) { |
163 return new GpuBenchmarkingRenderingStats(); | 164 return new GpuBenchmarkingRenderingStats(); |
164 } | 165 } |
165 return new RafRenderingStats(); | 166 return new RafRenderingStats(); |
166 } | 167 } |
167 | 168 |
168 window.__RenderingStats = RenderingStats; | 169 window.__RenderingStats = RenderingStats; |
169 })(); | 170 })(); |
OLD | NEW |