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
<div id="parent">
<div test></div>
<div test></div>
<div foo></div>
</div>
/**
* Finds the first child element that satisfies the callback.
* @param {!Element} parent
* @param {function(!Element):boolean} callback
* @return {?Element}
*/
function childElement(parent, callback) {
for (let child = parent.firstElementChild; child;
child = child.nextElementSibling) {
if (callback(child)) {
return child;
}
}
return null;
}
/**
* Finds the first child element that has the specified attribute, optionally
* with a value.
* @param {!Element} parent
* @param {string} attr
* @param {string=} opt_value
* @return {?Element}
*/
function childElementByAttr(parent, attr, opt_value) {
return childElement(parent, el => {
if (!el.hasAttribute(attr)) {
return false;
}
if (opt_value !== undefined && el.getAttribute(attr) != opt_value) {
return false;
}
return true;
});
}
var parent = document.getElementById('parent');
Ready to run.
Test | Ops/sec | |
---|---|---|
Programmatic |
| ready |
querySelector |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.