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
check speeds with different elements
<style>
#template, #clone { display:none; };
</style>
<div id="template" class="class1 class2 class3">This is a div with an id, some classes, and text content. Suppose it needed to be cloned. Would it be faster to deep clone or create a new element and then set its textContent</div>
<script>
var div = document.getElementById('template'),
text = div.textContent,
classes = div.className;
function CloneAndAppend(){
var el = div.cloneNode(true);
el.setAttribute('id','clone');
document.body.appendChild(el);
}
function CreateAndAppend(){
var el = document.createElement('div');
el.setAttribute('id','clone');
el.textContent = text;
el.className = classes;
document.body.appendChild(el);
}
</script>
document.body.removeChild(document.getElementById('clone'));
Ready to run.
Test | Ops/sec | |
---|---|---|
Clone Deep |
| ready |
Create |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.