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

Side by Side Diff: chrome/test/data/perf/frame_rate/head.js

Issue 7068005: Revert 86568 - Add initial framework for performance tests that measure frame rate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var __running = false;
6 var __old_title = "";
7 var __scroll_by = 300;
8 var __raf;
9
10 var __t_last;
11 var __t_est;
12 var __t_est_total;
13 var __t_est_squared_total;
14 var __t_count;
15
16 function __init_stats() {
17 __t_last = undefined;
18 __t_est = undefined;
19 __t_est_total = 0;
20 __t_est_squared_total = 0;
21 __t_count = 0;
22 }
23 __init_stats();
24
25 function __calc_results() {
26 var M = __t_est_total / __t_count;
27 var X = __t_est_squared_total / __t_count;
28 var V = X - M * M;
29 var S = Math.sqrt(V);
30
31 var R = new Object();
32 R.mean = 1000.0 / M;
33 R.sigma = R.mean - 1000.0 / (M + S);
34 return R;
35 }
36
37 function __scroll_down() {
38 var y = window.scrollY;
39 window.scrollBy(0, __scroll_by);
40 if (window.scrollY == y)
41 __stop();
42 }
43
44 function __update_fps() {
45 var t_now = new Date().getTime();
46 if (window.__t_last) {
47 var t_delta = t_now - __t_last;
48 if (window.__t_est) {
49 __t_est = (0.1 * __t_est) + (0.9 * t_delta); // low-pass filter
50 } else {
51 __t_est = t_delta;
52 }
53 var fps = 1000.0 / __t_est;
54 document.title = "FPS: " + (fps | 0);
55
56 __t_est_total += t_delta;
57 __t_est_squared_total += t_delta * t_delta;
58 __t_count++;
59 }
60 __t_last = t_now;
61 }
62
63 function __sched_update() {
64 if (!__raf) {
65 if ("webkitRequestAnimationFrame" in window)
66 __raf = webkitRequestAnimationFrame;
67 else if ("mozRequestAnimationFrame" in window)
68 __raf = mozRequestAnimationFrame;
69 }
70 __raf(function() {
71 if (!__running)
72 return;
73 __update_fps();
74 __scroll_down();
75 __sched_update();
76 });
77 }
78
79 function __start() {
80 if (__running)
81 return;
82 __old_title = document.title;
83 __running = true;
84 __sched_update();
85 }
86
87 function __stop() {
88 __running = false;
89 document.title = __old_title;
90 }
91
92 function __reset() {
93 __stop();
94 document.body.scrollTop = 0;
95 __init_stats();
96 }
97
98 function __force_compositor() {
99 document.body.style.webkitTransform = "translateZ(0)";
100 }
OLDNEW
« no previous file with comments | « chrome/test/data/perf/frame_rate/blank/test.html ('k') | chrome/test/perf/frame_rate/frame_rate_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698