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 for (var i = 0; i < 1000; i++) { | 6 for (var i = 0; i < 1000; i++) { |
7 var div = document.createElement("div"); | 7 var div = document.createElement("div"); |
8 div.id = "foo" + i; | 8 div.id = "foo" + i; |
9 div.className = "bar" + i; | 9 div.className = "bar" + i; |
10 document.body.appendChild(div); | 10 document.body.appendChild(div); |
11 } | 11 } |
12 | 12 |
13 var h1 = document.createElement("h1"); | 13 var h1 = document.createElement("h1"); |
14 h1.id = "id"; | 14 h1.id = "id"; |
15 h1.className = "class"; | 15 h1.className = "class"; |
16 document.body.appendChild(h1); | 16 document.body.lastChild.appendChild(h1); |
17 | 17 |
18 PerfTestRunner.measureRunsPerSecond({ | 18 PerfTestRunner.measureRunsPerSecond({ |
19 description: "This benchmark tests querySelector() for an element that appea
rs near the tail of the document", | 19 description: "This benchmark tests querySelector() for an element that appea
rs near the tail of the document, and is a child of an element with a given id", |
20 run: function() { | 20 run: function() { |
21 for (var i = 0; i < 100; i++) { | 21 for (var i = 0; i < 100; i++) { |
22 document.querySelector("h1"); | 22 var res = document.querySelector("#foo999 > h1"); |
23 document.querySelector("#id"); | |
24 document.querySelector(".class"); | |
25 } | 23 } |
26 }}); | 24 }}); |
27 </script> | 25 </script> |
28 </body> | 26 </body> |
29 </html> | 27 </html> |
OLD | NEW |