internal-data

JavaScript performance comparison

Revision 3 of this test case created by Corey Frang

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script> jQ164 = jQuery.noConflict(); </script>
<script src="https://gnarf.net/jquery-1.7-data.js"></script>

      
<script>
Benchmark.prototype.setup = function() {
  var html = "<div data-testing='omg' data-again='1' class='testing'>",
      onesix = jQ164( html ),
      unicorns = $( html );
  
  jQ164._data( onesix[0], { test: 1 });
  $._data( unicorns[0], { test: 1 });

};
</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
.data() - 1.6
onesix.data()
pending…
.data() - test
unicorns.data()
pending…
set private - 1.6
jQ164._data( onesix[0], { test: true } )
pending…
set private - test
$._data( unicorns[0], { test: true } )
pending…
get private - 1.6
jQ164._data( onesix[0], "test" )
pending…
get private - test
$._data( unicorns[0], "test" );
pending…
get attr - 1.6
onesix.data( "testing" );
pending…
get attr - test
unicorns.data( "testing" );
pending…
set public - 1.6
onesix.data( "public", "testing" );
pending…
set public - test
unicorns.data( "public", "testing" );
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