dom-vs-ccf

JavaScript performance comparison

Revision 2 of this test case created by Kris Selden

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function usingCCF(html) {
      var element = document.createElement("div");
      var range = document.createRange();
      range.setStart(element);
      range.collapse(false);
      return range.createContextualFragment(html);
    }
   
    function usingPrecompiler() {
      var document = this.document;
      var element0 = document.createDocumentFragment();
      var frag = element0;
      var element1 = el = document.createElement('div');
      el.setAttribute('class', 'foo');
      var element2 = el = document.createElement('p');
      var element3 = el = document.createElement('span');
      el.setAttribute('id', 'bar');
      el.setAttribute('data-foo', 'bar');
      element3.appendChild(document.createTextNode('hi!'));
      element2.appendChild(element3);
      element1.appendChild(element2);
      element0.appendChild(element1);
      element0.appendChild(document.createTextNode(' More content'));
      return frag;
    }
};
</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
usingCCF();
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