Troop instance property addition

JavaScript performance comparison

Test case created by Dan Stocker

Info

Test compares instantiation of Troop classes with or without 'proper' property definitions.

Preparation code

<script src="http://dl.dropbox.com/u/9258903/JavaScript/dessert-0.2.7.js">
</script>
<script src="http://dl.dropbox.com/u/9258903/JavaScript/troop-0.3.3.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var WithAssignment = troop.Base.extend().addMethod({
      init: function() {
        this.foo = "bar";
      }
    });
   
    var WithTroop = troop.Base.extend().addMethod({
      init: function() {
        this.addPublic({
          foo: "bar"
        });
      }
    });
};
</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
With assignment
WithAssignment.create();
pending…
With troop property definition
WithTroop.create();
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