Init Me's

JavaScript performance comparison

Revision 2 of this test case created by Josh

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var foo = {};
    var bar = function() {this.prop1_ = function() {return 4;};};
   
    foo.run = function() {
        this.prop1_ = function() {return 4;};
        this.prop2_ = function() {return true;};
        this.prop3_ = function() {return [];};
        this.prop4_ = function() {return 'blah';};
        };
   
   
    bar.prototype.prop2_ = function() {return true;};
    bar.prototype.prop3_ = function() {return [];};
    bar.prototype.prop4_ = function() {return '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
var a;
foo.run();
a = foo.prop_1;
a = foo.prop_2;
a = foo.prop_3;
a = foo.prop_4;
pending…
good
var a;
bar;
a = bar.prop_1;
a = bar.prop_2;
a = bar.prop_3;
a = bar.prop_4;
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