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
This actually benchmarks what it says it is (most of these other tests just test against an empty element because setup only fires once per benchmark, not per iteration.
Also using a clone to repopulate the html means that the test time is less skewed by refreshing the dom to a state to benchmark.
<div id="box"></div>
<script>
var boxAnchor = document.createElement('div');
boxAnchor.style.cssText="white-space:nowrap";
boxAnchor.id = 'box';
for(var i=0;i<1000;i++)
{
boxAnchor.appendChild(document.createElement('B').insertBefore(document.createTextNode('asdf fewf')).parentNode);
}
var box=document.getElementById('box');
function refreshRange()
{
box.parentNode.replaceChild(boxAnchor.cloneNode(true),box);
box=document.getElementById('box');
}
var range = document.createRange();
refreshRange();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
Ready to run.
Test | Ops/sec | |
---|---|---|
removeChild Recheck |
| ready |
removeChild lastChild with reference |
| ready |
firstChild haschildnodes() check |
| ready |
deletecontents (IE9+) |
| ready |
replaceChild cloneNode(shallow) (DESTRUCTIVE) |
| ready |
removeChild then reAttach |
| ready |
innerhtml = "" |
| ready |
jquery |
| ready |
hide |
| ready |
innerText |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.