append/prepend withlookup

JavaScript performance comparison

Test case created

Preparation code

<div id="par">
<div id="stuff" />
<div id="more" />
</div>
<script>
Benchmark.prototype.setup = function() {
    var stuff = document.getElementById('stuff');
    var more = document.getElementById('more');
    var par = document.getElementById('par');
    var div = document.createElement('div');
    div.innerHTML = "<div>hi<b>stuff</b>adss</div>";
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
prepend
par.insertBefore(more, div);
pending…
append
par.appendChild(div);
pending…
prepend lookup first
if (par.childNodes[1]) {
  par.insertBefore(more, div);
}
pending…
append lookup first
if (par.childNodes[1]) {
  par.appendChild(div);
}
pending…

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

Compare results of other browsers

0 comments

Add a comment