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