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
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul>
<li id="first"></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li="test"></li><li></li><li></li><li></li><li id="last"></li>
</ul>
<script>
var f = $("#first"),
l = $("#last"),
sub = jQuery.sub(),
l2 = sub("#last");
sub.fn.index = function(elem) {
if (!elem) {
return this.prevAll().length;
}
if (typeof elem === "string") {
return jQuery.inArray(this[0],
// If it receives a string, the selector is used
// If it receives nothing, the siblings are used
elem ? jQuery(elem) : this.parent().children());
}
// Locate the position of the desired element
return jQuery.inArray(
// If it receives a jQuery object, the first element is used
elem.jquery ? elem[0] : elem, this);
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
index #first |
| ready |
prevall #first |
| ready |
index #last |
| ready |
prevall #last |
| ready |
rewritten #last |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.