dom-vs-ccf

JavaScript performance comparison

Revision 5 of this test case created

Preparation code

<script>
(function() {
  var doc = document;
  window.usingCCF = function(html) {
    var element = doc.createElement("div");
    var range = doc.createRange();
    range.setStart(element, 0);
    range.collapse(false);
    return range.createContextualFragment(html);
  };

  window.usingPrecompiler = function(document) {
    var element0 = doc.createDocumentFragment();
    var element1 = doc.createElement('div');

    element1.className = 'foo';
    var element2 = doc.createElement('p');
    var element3 = doc.createElement('span');
    element3.id = 'bar';
    element3.setAttribute('data-foo', 'bar');
    element3.text = 'hi!';

    element2.appendChild(element3);
    element1.appendChild(element2);
    element0.appendChild(element1);
    element0.text = ' More content';
    return element0;
  };
})();
</script>
<script>
Benchmark.prototype.setup = function() {
    var usingCCF = window.usingCCF;
    var usingPrecompiler = window.usingPrecompiler;
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
ccf
var html = '<div class="foo">';
var hi = 'hi!';
html += '<p>';
html += '<span id="bar" data-foo="bar">';
html += hi;
html += '</span>';
html += '</p>';
html += '</div>';
html += ' More content';
usingCCF(html);
pending…
precompiler
usingPrecompiler();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment