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 id="test">
<li class="test">test</li>
<li class="test">test</li>
<li class="test">test</li>
<li class="test">test</li>
<li class="test">test</li>
<li class="test">test</li>
</ul>
<script>
;// just in case
(function (win) {
win.g = win.g || {init:[]};
var doc = document;
g.init.push(
function _assignClassMethod() {
if (doc.getElementsByClassName) {
g.c = function _getElsByClass(className, context) {
context = context || doc;
return context.getElementsByClassName(className);
};
} else if (doc.evaluate) { // Supports XPath
g.c = function _getElsByClass(className, context) {
var tag = '*',
context = context || doc,
retArr = [];
elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
while ((node = elements.iterateNext())) {
retArr.push(node);
}
return retArr;
};
} else {
g.c = function _getElsByClass(className, context) {
context = context || doc;
var childElements = context.getElementsByTagName("*"),
retArr = [],
regex = new RegExp("(^|\\s)" + className + "(\\s|$)"); // can't use word boundaries (\b) because "help" and "help-me" would both be returned.
for (var i = 0, len = childElements.length; i < len; i++) {
if (regex.test(childElements[i].className))
retArr.push(childElements[i]);
}
return retArr;
};
}
},
function _assignIdMethod() {
g.i = function _getElementById(id) {
return doc.getElementById(id);
};
},
function _assignTagMethod() {
g.t = function _getElementsByTag(tag, context) {
context = context || doc;
return context.getElementsByTagName(tag);
};
},
function _assignFindMethod() {
g.f = function _find(selector, context) {
var iReg = /^#([-a-zA-Z0-9_]+)$/,
cReg = /^\.([-a-zA-Z0-9_]+)$/,
tReg = /^[a-zA-Z]+$/,
context = context || doc,
sizzle = jQuery && jQuery.find;
if (iReg.test(selector))
return g.i(selector.substring(1));
if (cReg.test(selector))
return g.c(selector.substring(1), context);
if (tReg.test(selector))
return g.t(selector, context);
if (sizzle)
return context ? sizzle(selector, context) : sizzle(selector);
return false;
};
}
);
for (var i = 0, len = g.init.length; i < len; i++) {
g.init[i]();
}
}(window));
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
jquery |
| ready |
custom find |
| ready |
custom public |
| ready |
custom public to jquery |
| ready |
custom find to jquery |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.