OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <script src="../resources/runner.js"></script> | |
3 <pre id="log"></pre> | |
4 <script> | |
5 // We discard the first iteration to avoid a cold outlier. | |
6 var iterations = 11; | |
7 var results = []; | |
8 var previousFrameTime = -1; | |
9 var now = function(){ | |
10 return window.performance ? performance.now() : Date.now(); | |
11 }; | |
12 | |
13 function createTable(rows, columns) { | |
14 var table = document.createElement("TABLE"); | |
15 // Collapsing border is not necessary to see the slowness | |
16 // but it makes the painting phase ~2x slower. | |
17 table.style.borderCollapse = "collapse"; | |
18 for (var i = 0; i < rows; ++i) { | |
19 var tr = document.createElement("TR"); | |
20 for (var j = 0; j < columns; ++j) { | |
21 var td = document.createElement("TD"); | |
22 tr.appendChild(td); | |
23 } | |
24 table.appendChild(tr); | |
25 } | |
26 return table; | |
27 } | |
28 | |
29 | |
30 var table = createTable(300, 320); | |
31 document.body.appendChild(table); | |
32 | |
33 ix=30; | |
34 iy=30; | |
35 | |
36 function toggleBackgroundColor() | |
37 { | |
38 var thisFrameTime = now(); | |
39 if (previousFrameTime != -1) | |
40 results.push(thisFrameTime - previousFrameTime); | |
41 previousFrameTime = thisFrameTime; | |
42 | |
43 if (iterations == 0) { | |
44 PerfTestRunner.logStatistics(results, 'ms', "Time:"); | |
45 if (window.testRunner) | |
46 testRunner.notifyDone(); | |
47 } else { | |
48 iterations--; | |
49 window.requestAnimationFrame(toggleBackgroundColor); | |
50 } | |
51 | |
52 table.childNodes[iy].childNodes[ix].style.backgroundColor = 'teal'; | |
53 ix++; | |
54 iy++; | |
55 } | |
56 | |
57 if (window.testRunner) | |
58 testRunner.waitUntilDone(); | |
59 | |
60 // Start the test after two frame to ensure we have set-up, laid out and painted
the table. | |
61 window.requestAnimationFrame(function() { window.requestAnimationFrame(toggleBac
kgroundColor) }); | |
62 </script> | |
OLD | NEW |