Init Me's

JavaScript performance comparison

Test case created by Josh

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    foo = {};
   
    foo.Baz = function() {
      this.prop1_ = 4;
      this.prop2_ = true;
      this.prop3_ = [];
      this.prop4_ = 'blah';
    };
   
    foo.Bar = function() {
      this.prop3_ = [];
    };
   
    foo.Bar.prototype.prop1_ = 4;
   
    foo.Bar.prototype.prop2_ = true;
   
    foo.Bar.prototype.prop4_ = 'blah';
};
</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
bad
foo.Baz();
pending…
good
foo.Bar();
pending…
Bad tested
var a;
foo.Baz();
a = foo.prop1;
a = foo.prop2;
a = foo.prop3;
a = foo.prop4;
pending…
Good tested
var a;
foo.Bar();
a = foo.prop1;
a = foo.prop2;
a = foo.prop3;
a = foo.prop4;
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