Skip to content

Commit 96d8c48

Browse files
committed
Some improvements to the closest perf tests - works in all browsers now.
1 parent 0ca35de commit 96d8c48

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

speed/closest.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
jQuery(function ready() {
1111
var node = $("#child"), name;
1212

13-
[".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"].forEach(function foreach(item) {
13+
jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
1414
name = "closest '" + item + "'";
15-
console.log(name);
1615

17-
console.log("new", benchmarkString("$('#child').closest('" + item + "')", 5000, name));
18-
console.log("old", benchmarkString("old('#child').closest('" + item + "')", 5000, name));
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>");
1920
});
2021
});
21-
</script>
22+
</script>
2223
</head>
2324
<body>
2425
<div>
@@ -30,6 +31,7 @@
3031
</div>
3132
</div>
3233
</div>
34+
<ul id="results"></ul>
3335
</body>
3436
</html>
3537

0 commit comments

Comments
 (0)