Accessors

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function Foo(a) {
    this.a = a;
    }
   
    Foo.prototype.getA = function() {
    return this.a * this.a;
    }
   
    function Bar(a) {
      this.getA = function() {return a * a};
    }
   
    function Baz(a) {
       function getA() {return a * a};
   
    return {getA: getA};
    }
   
    var foo = new Foo(5);
    var bar = new Bar(5);
    var baz = new Baz(5);
};
</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
Protos
foo.getA();
pending…
Instances
bar.getA()
pending…
Closures
baz.getA()
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