Calls to different types of functions

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var Stuff1 = {
    a : 20,
    b : 2.1,
    func1 : function() {
    return this.a*this.b;
    }
    };
   
    function Stuff2() {
    var c = 20;
    var d = 2.1;
    function func2() {
    return c*d;
    }
    this.func2 = func2;
    this.func3 = function() {
    return c*d;
    }
    }
   
    Stuff2.prototype.e = 20;
    Stuff2.prototype.f = 2.1;
    Stuff2.prototype.func4 = function() {
    return this.e*this.f;
    }
   
    var stuff = new Stuff2();
};
</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
within object
Stuff1.func1();
pending…
private -> public
stuff.func2();
pending…
public
stuff.func3();
pending…
prototype
stuff.func4();
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