Iterating backwards over HTMLCollection is O(n^2)
[WebKit-https.git] / LayoutTests / perf / htmlcollection-backwards-iteration.html
1 <!DOCTYPE html>
2 <body>
3 <div id="container" style="display: none;"></div>
4 <script src="../resources/magnitude-perf.js"></script>
5 <script>
6
7 var container = document.getElementById('container');
8
9 function setupFunction(magnitude)
10 {
11     container.innerHTML = '';
12     for (var i = 0; i < magnitude; i++)
13         container.appendChild(document.createElement('div'));
14 }
15
16 function test(magnitude)
17 {
18     var children = container.children;
19     for (var i = children.length; i > 0;i--)
20         children[i - 1].class = 'hi';
21 }
22
23 Magnitude.description("Tests that iterating over HTMLCollection backwards is linear.");
24 Magnitude.run(setupFunction, test, Magnitude.LINEAR);
25
26 </script>
27 </body>
28 </html>