Chromium Code Reviews| Index: chrome/test/data/perf/latency_suite.html |
| diff --git a/chrome/test/data/perf/latency_suite.html b/chrome/test/data/perf/latency_suite.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e4ecedc1c7cf710ccc6867f71fa1f29ed231a249 |
| --- /dev/null |
| +++ b/chrome/test/data/perf/latency_suite.html |
| @@ -0,0 +1,155 @@ |
| +<html> |
| +<head> |
| +<script type="text/javascript"> |
| +var frameCountWarmup = 5; |
|
nduca
2011/12/21 20:24:23
You might want a
/**
* @fileoverview Blahblahblah
jbates
2011/12/22 02:41:17
Done.
|
| +var frameCount = 0; |
| +var numFrames = 0; |
| +var inputDirty = false; |
| +var inputHeavy = false; |
| +var rafHeavy = false; |
| +var paintHeavy = false; |
| +var mode = "webgl"; |
|
nduca
2011/12/21 20:24:23
single quotes in js
jbates
2011/12/22 02:41:17
Done.
|
| +var delayTimeMS = 0; |
| +var canvasWidth = 0; |
| +var clearColorGreen = 0; |
| +var gl = null; |
| +var mouse_x = 0; |
|
nduca
2011/12/21 20:24:23
mouseX, expect_y
jbates
2011/12/22 02:41:17
Done.
|
| +var expect_y = 0; |
| + |
| +function getParam(key) { |
|
nduca
2011/12/21 20:24:23
You'd be better served having this return a dictio
jbates
2011/12/22 02:41:17
Done.
|
| + var query = window.location.href.split('?')[1]; |
|
nduca
2011/12/21 20:24:23
window.location.query.substring(1)?
jbates
2011/12/22 02:41:17
Done.
|
| + if(!query) |
|
nduca
2011/12/21 20:24:23
On your linux box, run gjslint --strict --check_ht
jbates
2011/12/22 02:41:17
Done.
|
| + return ""; |
| + var params = query.split('&'); |
| + for(var i = 0, len = params.length; i < len; i++) { |
| + var pair = params[i].split('='); |
| + if (key == pair[0]) |
| + return pair[1]; |
| + } |
| + return ""; |
| +} |
| + |
| +function parseParams() { |
| + numFrames = parseInt(getParam("numFrames")); |
| + expect_y = parseInt(getParam("y")); |
| + inputDirty = (getParam("inputDirty") == "true"); |
| + inputHeavy = (getParam("inputHeavy") == "true"); |
| + rafHeavy = (getParam("rafHeavy") == "true"); |
| + paintHeavy = (getParam("paintHeavy") == "true"); |
|
nduca
2011/12/21 20:24:23
So you have to put &paintHeavy=true in the uri? Wh
jbates
2011/12/22 02:41:17
Done.
|
| + mode = getParam("mode"); |
| + delayTimeMS = parseInt(getParam("delayTimeMS")); |
| + canvasWidth = parseInt(getParam("canvasWidth")); |
| + clearColorGreen = parseInt(getParam("clearColorGreen")); |
| +} |
| + |
| +function setCoordinates(e) { |
| + // Ignore mouse events with wrong Y coordinate. |
| + if (e.clientY != expect_y) |
| + return; |
| + |
| + mouse_x = e.clientX; |
| + if (inputDirty) { |
| + document.getElementById("text").firstChild.nodeValue = |
|
nduca
2011/12/21 20:24:23
nodeValue -> textContent
jbates
2011/12/22 02:41:17
Done.
|
| + mouse_x.toString(); |
| + } |
| + if (inputHeavy) { |
| + delay(delayTimeMS); |
| + } |
| +} |
| + |
| +function init() { |
| + parseParams(); |
| + |
| + if (mode == "webgl") { |
| + var canvas = document.getElementById("canvas"); |
| + if (!canvas) |
| + return false; |
| + canvas.width = canvasWidth; |
| + canvas.height = canvasWidth; |
| + try { |
| + gl = canvas.getContext("webgl", { antialias: true }); |
| + } catch(e) {} |
| + if (!gl) { |
| + try { |
| + gl = canvas.getContext("experimental-webgl"); |
| + } catch(e) { |
| + return false; |
| + } |
| + } |
| + return true; |
| + } else if (mode == "software") { |
| + var table = document.getElementById("table"); |
| + table.style.backgroundColor = '#ff00ff'; |
| + return true; |
| + } |
| +} |
| + |
| +function runTest() { |
|
nduca
2011/12/21 20:24:23
by the name, i assumed this was called by dom auto
jbates
2011/12/22 02:41:17
Done.
|
| + if (init()) |
| + window.webkitRequestAnimationFrame(draw); |
| + else |
| + endTest(); |
| +} |
| + |
| +function delay(milliseconds) { |
|
nduca
2011/12/21 20:24:23
s/delay/sleep/?
jbates
2011/12/22 02:41:17
Done.
|
| + var start = new Date(); |
| + var now = null; |
| + do { now = new Date(); } |
|
nduca
2011/12/21 20:24:23
I think you can do this as two lines:
var start =
jbates
2011/12/22 02:41:17
Done.
|
| + while (now - start < milliseconds); |
| +} |
| + |
| +function xColorString() { |
|
nduca
2011/12/21 20:24:23
pass in x_ instead and give this a sane name? Or j
jbates
2011/12/22 02:41:17
Done.
|
| + var hexColor = mouse_x.toString(16); |
| + var color = "#000000"; |
| + return color.substring(0, 7 - hexColor.length) + hexColor; |
| +} |
| + |
| +function draw() { |
| + frameCount++; |
| + if (frameCount == numFrames) { |
| + endTest(); |
| + } |
| + |
| + if (rafHeavy) { |
| + delay(delayTimeMS); |
| + } |
| + |
| + if (mode == "webgl") { |
| + gl.viewport(0, 0, canvasWidth, canvasWidth); |
| + if (paintHeavy) { |
| + gl.clearColor(0, 0, 0.0, 1.0); |
| + for (var i = 0; i < 1000; ++i) |
| + gl.clear(gl.COLOR_BUFFER_BIT); |
| + } |
| + gl.clearColor(mouse_x, clearColorGreen, 0.0, 1.0); |
| + gl.clear(gl.COLOR_BUFFER_BIT); |
| + } else if (mode == "software") { |
| + var table = document.getElementById("table"); |
| + table.style.backgroundColor = xColorString(); |
| + // When no inputs are coming in, the first table won't change. Since we |
| + // still need to cause a paint, toggle the color of another element: |
| + var table2 = document.getElementById("table2"); |
| + table2.style.backgroundColor = (frameCount & 1) ? 'red' : 'black'; |
| + if (paintHeavy) { |
| + var body = document.getElementById("body"); |
| + body.style.backgroundColor = (frameCount & 1) ? 'black' : 'red'; |
| + } |
| + } |
| + |
| + window.webkitRequestAnimationFrame(draw); |
| +} |
| + |
| +function endTest() { |
| + domAutomationController.setAutomationId(1); |
| + domAutomationController.send("FINISHED"); |
| +} |
| +</script> |
| +</head> |
| +<body id="body" style="margin:0px" onload="runTest()" |
| + onmousemove="setCoordinates(event)"> |
| +<table id="table" width="10" height="10"><tr/></table> |
|
nduca
2011/12/21 20:24:23
Any reason you're using a table rather than just a
jbates
2011/12/22 02:41:17
div didn't maintain its size for some reason, so I
|
| +<table id="table2" width="10" height="10"><tr/></table> |
| +<canvas id="canvas" width="10" height="10"></canvas> |
|
nduca
2011/12/21 20:24:23
why initialize widths here if you initialize it up
jbates
2011/12/22 02:41:17
Done.
|
| +<p><b id="text">x</b></p> |
| +</body> |
| +</html> |