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

Side by Side Diff: chrome/test/data/perf/latency/latency_suite.html

Issue 8883005: Input latency performance test that uses tracing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 9 years 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 <html>
2 <head>
3 <script type="text/javascript">
4 var frameCountWarmup = 5;
5 var frameCount = 0;
6 var numFrames = 0;
7 var inputDirty = false;
8 var inputHeavy = false;
9 var rafHeavy = false;
10 var paintHeavy = false;
11 var mode = "webgl";
12 var delayTimeMS = 0;
13 var canvasWidth = 0;
14 var clearColorGreen = 0;
15 var gl = null;
16 var mouse_x = 0;
17 var expect_y = 0;
18
19 function getParam(key) {
20 var query = window.location.href.split('?')[1];
21 if(!query)
22 return "";
23 var params = query.split('&');
24 for(var i = 0, len = params.length; i < len; i++) {
25 var pair = params[i].split('=');
26 if (key == pair[0])
27 return pair[1];
28 }
29 return "";
30 }
31
32 function parseParams() {
33 numFrames = parseInt(getParam("numFrames"));
34 expect_y = parseInt(getParam("y"));
35 inputDirty = (getParam("inputDirty") == "true");
36 inputHeavy = (getParam("inputHeavy") == "true");
37 rafHeavy = (getParam("rafHeavy") == "true");
38 paintHeavy = (getParam("paintHeavy") == "true");
39 mode = getParam("mode");
40 delayTimeMS = parseInt(getParam("delayTimeMS"));
41 canvasWidth = parseInt(getParam("canvasWidth"));
42 clearColorGreen = parseInt(getParam("clearColorGreen"));
43 }
44
45 function setCoordinates(e) {
46 // Ignore mouse events with wrong Y coordinate.
47 if (e.clientY != expect_y)
48 return;
49
50 mouse_x = e.clientX;
51 if (inputDirty) {
52 document.getElementById("text").firstChild.nodeValue =
53 mouse_x.toString();
54 }
55 if (inputHeavy) {
56 delay(delayTimeMS);
57 }
58 }
59
60 function init() {
61 parseParams();
62
63 if (mode == "webgl") {
64 var canvas = document.getElementById("canvas");
65 if (!canvas)
66 return false;
67 canvas.width = canvasWidth;
68 canvas.height = canvasWidth;
69 try {
70 gl = canvas.getContext("webgl", { antialias: true });
71 } catch(e) {}
72 if (!gl) {
73 try {
74 gl = canvas.getContext("experimental-webgl");
75 } catch(e) {
76 return false;
77 }
78 }
79 return true;
80 } else if (mode == "software") {
81 var table = document.getElementById("table");
82 table.style.backgroundColor = '#ff00ff';
83 return true;
84 }
85 }
86
87 function runTest() {
88 if (init())
89 window.webkitRequestAnimationFrame(draw);
90 else
91 endTest();
92 }
93
94 function delay(milliseconds) {
95 var start = new Date();
96 var now = null;
97 do { now = new Date(); }
98 while (now - start < milliseconds);
99 }
100
101 function xColorString() {
102 var hexColor = mouse_x.toString(16);
103 var color = "#000000";
104 return color.substring(0, 7 - hexColor.length) + hexColor;
105 }
106
107 function draw() {
108 frameCount++;
109 if (frameCount == numFrames) {
110 endTest();
111 }
112
113 if (rafHeavy) {
114 delay(delayTimeMS);
115 }
116
117 if (mode == "webgl") {
118 gl.viewport(0, 0, canvasWidth, canvasWidth);
119 if (paintHeavy) {
120 gl.clearColor(0, 0, 0.0, 1.0);
121 for (var i = 0; i < 1000; ++i)
122 gl.clear(gl.COLOR_BUFFER_BIT);
123 }
124 gl.clearColor(mouse_x, clearColorGreen, 0.0, 1.0);
125 gl.clear(gl.COLOR_BUFFER_BIT);
126 } else if (mode == "software") {
127 var table = document.getElementById("table");
128 table.style.backgroundColor = xColorString();
129 // When no inputs are coming in, the first table won't change. Since we
130 // still need to cause a paint, toggle the color of another element:
131 var table2 = document.getElementById("table2");
132 table2.style.backgroundColor = (frameCount & 1) ? 'red' : 'black';
133 if (paintHeavy) {
134 var body = document.getElementById("body");
135 body.style.backgroundColor = (frameCount & 1) ? 'black' : 'red';
136 }
137 }
138
139 window.webkitRequestAnimationFrame(draw);
140 }
141
142 function endTest() {
143 domAutomationController.setAutomationId(1);
144 domAutomationController.send("FINISHED");
145 }
146 </script>
147 </head>
148 <body id="body" style="margin:0px" onload="runTest()"
149 onmousemove="setCoordinates(event)">
150 <table id="table" width="10" height="10"><tr/></table>
151 <table id="table2" width="10" height="10"><tr/></table>
152 <canvas id="canvas" width="10" height="10"></canvas>
153 <p><b id="text">x</b></p>
154 </body>
155 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698