return this

JavaScript performance comparison

Test case created by pavel

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var Test_1 = function (val) {}
    Test_1.prototype.set = function(val) {
      this.a = val;
      return this;
    };
    var a = new Test_1();
   
    var Test_2 = function (val) {}
    Test_2.prototype.set = function(val) {
      this.a = val;
    };
   
    var b = new Test_2();
};
</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
with return this
a.set(0)
 .set(1)
 .set(2)
 .set(3)
 .set(4)
 .set(5)
 .set(6)
 .set(7)
 .set(8)
 .set(9);
pending…
withount return this
b.set(0);
b.set(1);
b.set(2);
b.set(3);
b.set(4);
b.set(5);
b.set(6);
b.set(7);
b.set(8);
b.set(9);
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