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
Checks whether scoped queryselectors are faster than document queryselectors
function button(text) {
const d = document.createElement("button");
d.textContent = text;
return d;
}
function span(children) {
const d = document.createElement("span");
d.append(...children);
return d;
}
const span1 = span([]);
const span2 = span([]);
document.body.append(span1, span2);
for (let i = 0; i < 1000; i++) {
const sp = span([span([]), span([])]);
span1.appendChild(sp);
}
for (let i = 0; i < 1000; i++) {
const btn = button('1');
btn.setAttribute('inert', '');
span2.appendChild(span([btn, button('2')]));
}
document.querySelectorAll('body > *').forEach(e => e.remove());
Ready to run.
Test | Ops/sec | |
---|---|---|
Document querySelector |
| ready |
Queryselector inside first span |
| ready |
Queryselector with scope |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.