jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
James Padolsey's quickEach plugin
My each2 plugin (which is like, almost the same as James')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var a = $('<div/>').append(Array(100).join('<a></a>')).find('a');
// James Padolsey's quickEach plugin
jQuery.fn.quickEach = (function() {
var jq = jQuery([1]);
return function(c) {
var i = -1,
el, len = this.length;
try {
while (++i < len && (el = jq[0] = this[i]) && c.call(jq, i, el) !== false);
} catch (e) {
delete jq[0];
throw e;
}
delete jq[0];
return this;
};
}());
// My each2 plugin
(function($) {
var jq = $([]);
$.fn.each2 = function(fn) {
var i = -1,
elem;
while ((elem = jq[0] = this[++i]) && fn.call(elem, i, jq) !== false) {}
return this;
};
})(jQuery);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
.each with no jQuery object |
| ready |
.each2 with no jQuery object |
| ready |
.quickEach with no jQuery object |
| ready |
.each with jQuery object |
| ready |
.each2 with jQuery object |
| ready |
.quickEach with jQuery object |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.