2010-10-10 06:33:02 +02:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2010-10-10 19:39:06 +02:00
|
|
|
<title>Test .closest() Performance</title>
|
2010-10-10 06:33:02 +02:00
|
|
|
<script src="benchmark.js"></script>
|
|
|
|
<script src="jquery-basis.js"></script>
|
|
|
|
<script>var old = jQuery.noConflict(true);</script>
|
|
|
|
<script src="../dist/jquery.js"></script>
|
|
|
|
<script>
|
|
|
|
jQuery(function ready() {
|
|
|
|
var node = $("#child"), name;
|
|
|
|
|
2010-10-10 19:22:39 +02:00
|
|
|
jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
|
2010-10-10 19:39:06 +02:00
|
|
|
setTimeout(function(){
|
|
|
|
name = "closest '" + item + "'";
|
2010-10-10 06:33:02 +02:00
|
|
|
|
2010-10-10 19:39:06 +02:00
|
|
|
jQuery("#results").append("<li>" + name + "<ul>" +
|
|
|
|
"<li>new: " + benchmarkString("$('#child').closest('" + item + "')", 2500, name) + "</li>" +
|
|
|
|
"<li>old: " + benchmarkString("old('#child').closest('" + item + "')", 2500, name) + "</li>"
|
|
|
|
+ "</ul></li>");
|
|
|
|
}, 100);
|
2010-10-10 06:33:02 +02:00
|
|
|
});
|
|
|
|
});
|
2010-10-10 19:22:39 +02:00
|
|
|
</script>
|
2010-10-10 06:33:02 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div>
|
|
|
|
<p>Hello</p>
|
|
|
|
<div class="zoo" id="zoo" data-foo="bar">
|
|
|
|
<div>
|
|
|
|
<p id="child">lorem ipsum</p>
|
|
|
|
<p>dolor sit amet</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2010-10-10 19:22:39 +02:00
|
|
|
<ul id="results"></ul>
|
2010-10-10 06:33:02 +02:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|