DOMNodeInsert

JavaScript performance comparison

Test case created by Josh

Preparation code

<div id="editor"></div>
<div id="rest"></div>
<script>
Benchmark.prototype.setup = function() {
    var editor = document.getElementById('editor');
    var rest = document.getElementById('rest');
    var listener = function() {}
    var addto = editor;
   
    function addNodes() {
    for (var i = 0; i < 10; i++) {
       addto.appendChild(document.createElement('div'));
    }
    }
};

Benchmark.prototype.teardown = function() {
    while (editor.childNodes) editor.removeChild(editor.childNodes[0]);
};
</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
Without listener
editor.addEventListener('click', listener, true, true);
addNodes();
editor.removeEventListener('click', listener, true);
pending…
With listener
editor.addEventListener('DOMNodeInserted', listener, true, true);
addNodes();
editor.removeEventListener('DOMNodeInserted', listener, true);

 
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