| Index: chrome/test/data/perf/latency/latency_suite.html
|
| diff --git a/chrome/test/data/perf/latency/latency_suite.html b/chrome/test/data/perf/latency/latency_suite.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e4ecedc1c7cf710ccc6867f71fa1f29ed231a249
|
| --- /dev/null
|
| +++ b/chrome/test/data/perf/latency/latency_suite.html
|
| @@ -0,0 +1,155 @@
|
| +<html>
|
| +<head>
|
| +<script type="text/javascript">
|
| +var frameCountWarmup = 5;
|
| +var frameCount = 0;
|
| +var numFrames = 0;
|
| +var inputDirty = false;
|
| +var inputHeavy = false;
|
| +var rafHeavy = false;
|
| +var paintHeavy = false;
|
| +var mode = "webgl";
|
| +var delayTimeMS = 0;
|
| +var canvasWidth = 0;
|
| +var clearColorGreen = 0;
|
| +var gl = null;
|
| +var mouse_x = 0;
|
| +var expect_y = 0;
|
| +
|
| +function getParam(key) {
|
| + var query = window.location.href.split('?')[1];
|
| + if(!query)
|
| + 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");
|
| + 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 =
|
| + 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() {
|
| + if (init())
|
| + window.webkitRequestAnimationFrame(draw);
|
| + else
|
| + endTest();
|
| +}
|
| +
|
| +function delay(milliseconds) {
|
| + var start = new Date();
|
| + var now = null;
|
| + do { now = new Date(); }
|
| + while (now - start < milliseconds);
|
| +}
|
| +
|
| +function xColorString() {
|
| + 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>
|
| +<table id="table2" width="10" height="10"><tr/></table>
|
| +<canvas id="canvas" width="10" height="10"></canvas>
|
| +<p><b id="text">x</b></p>
|
| +</body>
|
| +</html>
|
|
|