ca2017480b2ea8e8adedece6a28e26b2425211e4
[jquery.git] / speed / closest.html
1 <!doctype html>
2 <html>
3 <head>
4         <title>Test Event Handling Performance</title>
5         <script src="benchmark.js"></script>
6         <script src="jquery-basis.js"></script>
7         <script>var old = jQuery.noConflict(true);</script>
8         <script src="../dist/jquery.js"></script>
9   <script>
10     jQuery(function ready() {
11       var node = $("#child"), name;
12
13       jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
14         name = "closest '" + item + "'";
15
16         jQuery("#results").append("<li>" + name + "<ul>" +
17                 "<li>new: " + benchmarkString("$('#child').closest('" + item + "')", 500, name) + "</li>" +
18                 "<li>old: " + benchmarkString("old('#child').closest('" + item + "')", 500, name) + "</li>"
19                 + "</ul></li>");
20       });
21     });
22   </script>
23 </head>
24 <body>
25   <div>
26     <p>Hello</p>
27     <div class="zoo" id="zoo" data-foo="bar">
28       <div>
29         <p id="child">lorem ipsum</p>
30         <p>dolor sit amet</p>
31       </div>
32     </div>
33   </div>
34   <ul id="results"></ul>
35 </body>
36 </html>
37