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
Rewriting a list by traversing the DOM and using innerHTML / innerText / textContent, removing the entire list and using appendChild to reinsert it into the DOM, and by looping through a getElementsByTagName array.
Revision 2: Added childNodes method.
Revision 3: Added innerHTML on parent method, and some more complex html.
<style>
li { /*fixed size can improve performance*/
width: 200px;
height: 30px;
overflow: hidden;
}
</style>
<ul id="test">
<li my_id="a" title="a">a</li>
<li my_id="b" title="b">b</li>
<li my_id="c" title="c">c</li>
<li my_id="d" title="d">d</li>
<li my_id="e" title="e">e</li>
<li my_id="f" title="f">f</li>
<li my_id="g" title="g">g</li>
<li my_id="h" title="h">h</li>
<li my_id="i" title="i">i</li>
<li my_id="j" title="j">j</li>
</ul>
<script>
var oList = document.getElementById('test'),
arr = ['j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'];
function li(node, text) {
node.appendChild(document.createTextNode(text));
node.setAttribute('my_id', text);
return node;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
textContent |
| ready |
innerText |
| ready |
innerHTML |
| ready |
appendChild |
| ready |
getElementsByTagName |
| ready |
childNodes |
| ready |
innerHTML on parent |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.