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
Comparing 3 different ways to dynamically insert new elements into the DOM tree.
<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>
<script>
// You can read this:
// http://ejohn.org/blog/dom-documentfragments/
function text(node, txt) {
node.appendChild(document.createTextNode(txt));
return node;
}
function cleanUp(node) {
node.innerHTML = "";
}
var content = [ // I hate the way jsPerf formats arrays
document.createElement("hr"), text(document.createElement("b"), "Links:"), document.createTextNode(" "), text(document.createElement("a"), "Link A"), document.createTextNode(" | "), text(document.createElement("a"), "Link B"), document.createTextNode(" | "), text(document.createElement("a"), "Link C")];
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
appendChild |
| ready |
DocumentFragment |
| ready |
innerHTML |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.