Distant methods in prototype chain or indirect invocation

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function Foo() {
    this.x = 0;
    }
   
    Foo.prototype.doSomething = function () { this.x++; };
   
    function Foo2() {
    Foo.call(this);
    }
   
    Foo2.prototype = new Foo();
   
    function Foo3() {
    Foo2.call(this);
    }
   
    Foo3.prototype = new Foo2();
   
    function doSomething (fn) {
    this.x++;
    }
   
    var walkPrototype = new Foo3();
    var indirectInvocation = new Foo2();
};
</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
Walk prototype
walkPrototype.doSomething(indirectInvocation);
pending…
Indirect invocation:call
doSomething.call(indirectInvocation);
pending…
Indirect invocation:apply
doSomething.apply([indirectInvocation]);
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