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 |
removeFirstChild |
| ready |
remove lastChild |
| ready |
remove by count |
| ready |
forEach |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.