Object instantiation

Benchmark created by Andy Appleton on


Setup

var CloModule, cloInstance;
    
    // Define parent class
    CloModule = function(arg1, arg2, arg3){
      var self  = {
        getArg1:function(){
          return arg1;
        },
        getArg2: function(){
          return arg2;
        },
        getArg3: function(){
          return arg3;
        }
      };
      return self;
    };
    
    var ProtModule, protInstance;
    
    // Define parent class
    ProtModule = function(arg1, arg2, arg3){
      this.arg1 = arg1;
      this.arg2 = arg2;
      this.arg3 = arg3;
    };
    ProtModule.prototype.getArg1 = function(){
      return this.arg1;
    };
    ProtModule.prototype.getArg2 = function(){
      return this.arg2;
    };
    ProtModule.prototype.getArg3 = function(){
      return this.arg3;
    };

Teardown


    delete cloInstance;
    delete protInstance;
  

Test runner

Ready to run.

Testing in
TestOps/sec
Closure
cloInstance = new CloModule('arg1 contents', 'arg2 contents', 'arg3 contents');
ready
Prototype
protInstance = new ProtModule('arg1 contents', 'arg2 contents', 'arg3 contents');
ready

Revisions

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

  • Revision 1: published by Andy Appleton on