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

Unified Diff: chrome/test/data/perf/frame_rate/head.js

Issue 8052016: Adding support for animated pages in the FrameRate tests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/perf/frame_rate/head_animation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/perf/frame_rate/head.js
===================================================================
--- chrome/test/data/perf/frame_rate/head.js (revision 106936)
+++ chrome/test/data/perf/frame_rate/head.js (working copy)
@@ -34,6 +34,7 @@
* ],
*/
+var __initialized = true;
var __running = false;
var __running_all = false;
var __old_title = "";
@@ -52,14 +53,19 @@
var __recording = [];
var __advance_gesture;
-var __gestures = {
- none: [
+
+// This flag indicates whether the test page contains an animation loop
+// For more on testing animated pages, see head_animation.js
+var __animation = false;
+
+var __gesture_library = {
+ init: [
{"time_ms":1, "y":0},
- {"time_ms":5000, "y":0}
+ {"time_ms":5, "y":10}
],
- steady: [
+ stationary: [
{"time_ms":1, "y":0},
- {"time_ms":5, "y":10}
+ {"time_ms":5000, "y":0}
],
reading: [
{"time_ms":1, "y":0},
@@ -161,6 +167,26 @@
],
};
+// Stretch the duration of a gesture by a given factor
+function __gesture_stretch(gesture, stretch_factor) {
+ // clone the gesture
+ var new_gesture = JSON.parse(JSON.stringify(gesture));
+ for (var i = 0; i < new_gesture.length; ++i) {
+ new_gesture[i].time_ms *= stretch_factor;
+ }
+ return new_gesture;
+}
+
+// Gesture set to use for testing, initialized with default gesture set.
+// Redefine in test file to use a different set of gestures.
+var __gestures = {
+ none: __gesture_library["stationary"],
+ steady: __gesture_library["init"],
+ reading: __gesture_library["reading"],
+ mouse_wheel: __gesture_library["mouse_wheel"],
+ mac_fling: __gesture_library["mac_fling"],
+};
+
function __init_stats() {
__t_last = undefined;
__t_est = undefined;
@@ -170,6 +196,25 @@
}
__init_stats();
+function __init_raf() {
+ if ("requestAnimationFrame" in window)
+ __raf = requestAnimationFrame;
+ else if ("webkitRequestAnimationFrame" in window)
+ __raf = webkitRequestAnimationFrame;
+ else if ("mozRequestAnimationFrame" in window)
+ __raf = mozRequestAnimationFrame;
+ else if ("oRequestAnimationFrame" in window)
+ __raf = oRequestAnimationFrame;
+ else if ("msRequestAnimationFrame" in window)
+ __raf = msRequestAnimationFrame;
+ else
+ // No raf implementation available, fake it with 16ms timeouts
+ __raf = function(callback, element) {
+ setTimeout(callback, 16);
+ }
+}
+__init_raf();
+
function __calc_results() {
var M = __t_est_total / __t_count;
var X = __t_est_squared_total / __t_count;
@@ -328,14 +373,12 @@
}
function __sched_update() {
- if (!__raf) {
- if ("webkitRequestAnimationFrame" in window)
- __raf = webkitRequestAnimationFrame;
- else if ("mozRequestAnimationFrame" in window)
- __raf = mozRequestAnimationFrame;
- }
__raf(function() {
__raf_is_live = true;
+ // In case __raf falls back to using setTimeout, we must schedule the next
+ // update before rendering the current update to help maintain the
+ // regularity of update intervals.
+ __sched_update();
if (__running) {
// Only update the FPS if a gesture movement occurs. Otherwise, the frame
// rate average becomes inaccurate after any pause.
@@ -344,7 +387,6 @@
else
__t_last = new Date().getTime();
}
- __sched_update();
}, document.body);
}
@@ -361,8 +403,13 @@
return;
// Attempt to create a gesture function from a string name.
if (typeof gesture_function == "string") {
- if (!__gestures[gesture_function])
- throw new Error("Unrecognized gesture name");
+ if (!__gestures[gesture_function]) {
+ if (!__gesture_library[gesture_function])
+ throw new Error("Unrecognized gesture name");
+ else
+ gesture_function = __create_repeating_gesture_function(
+ __gesture_library[gesture_function]);
+ }
else
gesture_function = __create_repeating_gesture_function(
__gestures[gesture_function]);
@@ -374,7 +421,7 @@
__advance_gesture = gesture_function;
__t_start = new Date().getTime();
__running = true;
- if (!__raf_is_live) {
+ if (!__raf_is_live && !__animation) {
__sched_update();
}
}
@@ -392,8 +439,8 @@
__queued_gesture_functions.push(gesture);
}
__running_all = true;
- // Run steady gesture once to cache the webpage layout for subsequent tests.
- __start("steady");
+ // Run init gesture once to cache the webpage layout for subsequent tests.
+ __start("init");
}
function __stop() {
« no previous file with comments | « no previous file | chrome/test/data/perf/frame_rate/head_animation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698