OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <script src="../resources/runner.js"></script> | 4 <script src="../resources/runner.js"></script> |
5 <script> | 5 <script> |
6 var parentDiv = document.body; | 6 var parentDiv = document.body; |
7 for (var i = 0; i < 1000; i++) { | 7 for (var i = 0; i < 1000; i++) { |
8 var div = document.createElement("div"); | 8 var div = document.createElement("div"); |
9 div.id = "foo" + i; | 9 div.id = "foo" + i; |
10 div.className = "bar" + i; | 10 div.className = "bar" + i; |
11 parentDiv.appendChild(div); | 11 parentDiv.appendChild(div); |
12 parentDiv = div; | 12 parentDiv = div; |
13 } | 13 } |
14 | 14 |
15 var h1 = document.createElement("h1"); | 15 var h1 = document.createElement("h1"); |
16 h1.id = "id"; | 16 h1.id = "id"; |
17 h1.className = "class"; | 17 h1.className = "class"; |
18 parentDiv.appendChild(h1); | 18 parentDiv.appendChild(h1); |
19 | 19 |
20 PerfTestRunner.measureRunsPerSecond({ | 20 PerfTestRunner.measureRunsPerSecond({ |
21 description: "This benchmark tests querySelector() for an element that appea
rs in the depths in the document", | 21 description: "This benchmark tests querySelector() for an element that appea
rs in the depths in the document, and is a descendant of an element with a given
id", |
22 run: function() { | 22 run: function() { |
23 for (var i = 0; i < 100; i++) { | 23 for (var i = 0; i < 100; i++) { |
24 document.querySelector("h1"); | 24 var res = document.querySelector("#foo998 h1"); |
25 document.querySelector("#id"); | |
26 document.querySelector(".class"); | |
27 } | 25 } |
28 }}); | 26 }}); |
29 </script> | 27 </script> |
30 </body> | 28 </body> |
31 </html> | 29 </html> |
OLD | NEW |