jq2 data

JavaScript performance comparison

Revision 5 of this test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>window.jq1 = $;</script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>window.jq2 = $;</script>
      
<script>
Benchmark.prototype.setup = function() {
  var template = document.createElement("tr");
  for (var i=0; i<10; i++) {
      template.appendChild( document.createElement("td") );
  }
  
  function runDataTest($) {
      var p = $("<table class='jq-data-test'>").appendTo("body")[0]
  
      for (var i=0; i<50; i++) {
          var c = template.cloneNode(true);
          $.data(c, "foo", "#" + i);
          for (var j=0; j<10; j++) {
              $.data(c.children[j], "bar", "#" + i + "x" + j);
          }
          p.appendChild(c);
      }
  
      p.children[p.children.length-1].offsetTop;
  }

};

Benchmark.prototype.teardown = function() {
  $(".jq-data-test").remove();

};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
jQuery 1
runDataTest(jq1)
pending…
jQuery 2
runDataTest(jq2)
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.

0 Comments