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

Side by Side Diff: tools/gpu/gpu_tools/scroll.js

Issue 10916227: More polish in prep for CrOS support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for landing Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Inject this script on any page to measure framerate as the page is scrolled 5 // Inject this script on any page to measure framerate as the page is scrolled
6 // from top to bottom. 6 // from top to bottom.
7 // 7 //
8 // Usage: 8 // Usage:
9 // 1. Define a callback that takes a RenderingStats object as a parameter. 9 // 1. Define a callback that takes a RenderingStats object as a parameter.
10 // 2. To start the test, call new __ScrollTest(callback). 10 // 2. To start the test, call new __ScrollTest(callback).
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 requestAnimationFrame(this.recordFrameTime_.bind(this)); 115 requestAnimationFrame(this.recordFrameTime_.bind(this));
116 } 116 }
117 117
118 RafRenderingStats.prototype.stop = function() { 118 RafRenderingStats.prototype.stop = function() {
119 this.recording_ = false; 119 this.recording_ = false;
120 } 120 }
121 121
122 RafRenderingStats.prototype.get = function() { 122 RafRenderingStats.prototype.get = function() {
123 var results = {}; 123 var results = {};
124 results.numAnimationFrames = this.frameTimes_.length - 1; 124 results.numAnimationFrames = this.frameTimes_.length - 1;
125 results.numFramesSentToScreen = results.numFramesSentToScreen; 125 results.numFramesSentToScreen = results.numAnimationFrames;
126 results.droppedFrameCount = this.getDroppedFrameCount_(this.frameTimes_); 126 results.droppedFrameCount = this.getDroppedFrameCount_(this.frameTimes_);
127 results.totalTimeInSeconds = ( 127 results.totalTimeInSeconds = (
128 this.frameTimes_[this.frameTimes_.length - 1] - 128 this.frameTimes_[this.frameTimes_.length - 1] -
129 this.frameTimes_[0]) / 1000; 129 this.frameTimes_[0]) / 1000;
130 return results; 130 return results;
131 }; 131 };
132 132
133 RafRenderingStats.prototype.recordFrameTime_ = function(timestamp) { 133 RafRenderingStats.prototype.recordFrameTime_ = function(timestamp) {
134 if (!this.recording_) 134 if (!this.recording_)
135 return; 135 return;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // ensures this method will be called after the document is loaded. 182 // ensures this method will be called after the document is loaded.
183 this.element_ = opt_element || document.body; 183 this.element_ = opt_element || document.body;
184 // Some pages load more content when you scroll to the bottom. Record 184 // Some pages load more content when you scroll to the bottom. Record
185 // the original element height here and only scroll to that point. 185 // the original element height here and only scroll to that point.
186 this.scrollHeight_ = this.element_.scrollHeight 186 this.scrollHeight_ = this.element_.scrollHeight
187 requestAnimationFrame(this.startPass_.bind(this)); 187 requestAnimationFrame(this.startPass_.bind(this));
188 }; 188 };
189 189
190 ScrollTest.prototype.startPass_ = function() { 190 ScrollTest.prototype.startPass_ = function() {
191 this.element_.scrollTop = 0; 191 this.element_.scrollTop = 0;
192 if (window.chrome && chrome.gpuBenchmarking) 192 if (window.chrome && chrome.gpuBenchmarking &&
193 chrome.gpuBenchmarking.renderingStats)
193 this.renderingStats_ = new GpuBenchmarkingRenderingStats(); 194 this.renderingStats_ = new GpuBenchmarkingRenderingStats();
194 else 195 else
195 this.renderingStats_ = new RafRenderingStats(); 196 this.renderingStats_ = new RafRenderingStats();
196 this.renderingStats_.start(); 197 this.renderingStats_.start();
197 198
198 this.gesture_ = new SmoothScrollDownGesture(this.element_, 199 this.gesture_ = new SmoothScrollDownGesture(this.element_,
199 this.isGmailTest_); 200 this.isGmailTest_);
200 this.gesture_.start(this.onGestureComplete_.bind(this)); 201 this.gesture_.start(this.onGestureComplete_.bind(this));
201 }; 202 };
202 203
(...skipping 26 matching lines...) Expand all
229 console.log(this.renderingStats_.get()); 230 console.log(this.renderingStats_.get());
230 }; 231 };
231 232
232 ScrollTest.prototype.endPass_ = function() { 233 ScrollTest.prototype.endPass_ = function() {
233 this.renderingStats_.stop(); 234 this.renderingStats_.stop();
234 }; 235 };
235 236
236 237
237 window.__ScrollTest = ScrollTest; 238 window.__ScrollTest = ScrollTest;
238 })(); 239 })();
OLDNEW
« no previous file with comments | « tools/gpu/gpu_tools/multi_page_benchmark_unittest.py ('k') | tools/gpu/gpu_tools/scrolling_benchmark.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698