dom vs string

Benchmark created on


Preparation HTML

<div id="foo">
</div>
<script>
  var d = document.getElementById("foo");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
dom
d.innerHTML = "";

for (var i = 0; i < 100; i++) {
    var o = document.createElement("div");
    o.textContent = "hello";
    d.appendChild(o);
}
ready
string
d.innerHTML = "";

var str = "";
for (var i = 0; i < 100; i++) {
    str += "<div>hello</div>";
}
d.innerHTML = str;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.