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
From http://elv1s.ru/files/html+css/removeChildren.html
Test various ways of emptying an element of child nodes
<div id="container" style="display:none">
</div>
var container = document.getElementById('container'),
proto = addelements(document.createDocumentFragment());
function addelements(proto) {
var i = 200,
p, j, span;
while (i--) {
p = document.createElement('p');
j = 5;
while (j--) {
span = document.createElement('span');
span.appendChild(document.createTextNode(i * j + 'yada-yada'));
p.appendChild(span);
};
proto.appendChild(p);
};
return proto;
};
function prepare() {
container.appendChild(proto.cloneNode(false));
};
if (container.childNodes.length) {
throw "Container was not emptied!";
}
Ready to run.
Test | Ops/sec | |
---|---|---|
innerHTML |
| ready |
textContent |
| ready |
remove firstChild with var |
| ready |
remove lastChild with var |
| ready |
remove firstChild direct |
| ready |
remove lastChild direct |
| ready |
remove by count lastChild |
| ready |
remove by count firstChild |
| ready |
remove hasChildNodes firstChild |
| ready |
remove hasChildNodes lastChild |
| ready |
forEach |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.