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
Benchmark the creation of a complex DOM structure:
createElement
, setAttribute
, and appendChild
to create the structurecloneNode
of an existing node that represents the structure<script>
function generateNodes() {
var el0 = document.createElement("section");
el0.setAttribute("class", "section");
var el2 = document.createElement("header");
el2.setAttribute("class", "header");
el2.textContent = "Header";
el0.appendChild(el2);
var el4 = document.createElement("article");
el4.setAttribute("class", "article");
var el6 = document.createElement("p");
el6.textContent = "Paragraph 1";
el4.appendChild(el6);
var el8 = document.createElement("p");
el8.textContent = "Paragraph 2";
el4.appendChild(el8);
var el10 = document.createElement("p");
el10.textContent = "Paragraph 3";
el4.appendChild(el10);
var el12 = document.createElement("p");
el12.textContent = "Paragraph 4";
el4.appendChild(el12);
var el14 = document.createElement("p");
el14.textContent = "Paragraph 5";
el4.appendChild(el14);
var el16 = document.createElement("ul");
el16.setAttribute("class", "list");
var el18 = document.createElement("li");
el18.textContent = "Item 1";
el16.appendChild(el18);
var el20 = document.createElement("li");
el20.textContent = "Item 2";
el16.appendChild(el20);
var el22 = document.createElement("li");
el22.textContent = "Item 3";
el16.appendChild(el22);
var el24 = document.createElement("li");
el24.textContent = "Item 4";
el16.appendChild(el24);
var el26 = document.createElement("li");
el26.textContent = "Item 5";
el16.appendChild(el26);
el4.appendChild(el16);
el0.appendChild(el4);
var el30 = document.createElement("footer");
el30.setAttribute("class", "footer");
el30.textContent = "Footer";
el0.appendChild(el30);
return el0;
}
var div = generateNodes();
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Clone structure |
| ready |
Create structure |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.