pseudo-class-closure

Benchmark created by Francis on


Preparation HTML

<script>
  A = function() {
     this._factor = 2;
  }
  
  A.prototype = {
     methodA: function(value) {
        return this.methodB(value) * this._factor;
     },
     methodB: function(value) {
        return value * this._factor;
     }
  };
  
  B = function() {
     this._factor = 2;
  }
  
  B.prototype.methodA = function(value) {
     return this.methodB(value) * this._factor;
  }
  
  B.prototype.methodB = function(value) {
     return value * this._factor;
  }
  
  C = function() {
  var _factor = 2;
  
  this.methodA = function(value) {
  return this.methodB(value) * _factor;
  };
  
  this.methodB = function(value) {
  return value * _factor;
  }
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
json prototype
var a = new A();

a.methodA(100);
ready
prototype
var b = new B();

b.methodA(100);
ready
nested functions
var c = new C();

c.methodA(100);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Francis on