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
Different ways to dynamically insert new elements into the DOM tree. v44: Outer loop only 200, not 2000.
<div id="test1">
</div>
<script>
function precompileTemplate()
{
var docFrag=document.createDocumentFragment();
var tmplRow = document.createElement('div');
for (var j = 0; j < 20; j++)
{
var cell=document.createElement('span');
tmplRow.appendChild(cell);
}
for (var i = 0; i < 200; i++)
docFrag.appendChild(tmplRow.cloneNode(true));
return(docFrag);
}
var compiledTemplate1 = precompileTemplate();
</script>
var div1 = document.getElementById("test1");
var counter=0;
var row, cell;
div1.innerHTML='';
Ready to run.
Test | Ops/sec | |
---|---|---|
appendChild |
| ready |
DocumentFragment |
| ready |
innerHTML |
| ready |
Template-like 0 |
| ready |
Template-like 1 |
| ready |
innerHtml (bad) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.