Method Calling Test

JavaScript performance comparison

Test case created by Andy Appleton

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var CloModule,  cloInstance,
      ProtModule, protInstance;
  
  CloModule = function(arg1, arg2, arg3){
    var self = {
      getArg1:function(){
        return arg1;
      },
      getArg2: function(){
        return arg2;
      },
      getArg3: function(){
        return arg3;
      }
    };
    return self;
  };
  cloInstance = new CloModule('arg1 contents', 'arg2 contents', 'arg3 contents');
  
  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;
  };
  protInstance = new ProtModule('arg1 contents', 'arg2 contents', 'arg3 contents');
  

};

Benchmark.prototype.teardown = function() {
  delete cloInstance;
  delete protInstance;

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Closure
cloInstance.getArg1();
cloInstance.getArg2();
cloInstance.getArg3();
pending…
Prototype
protInstance.getArg1();
protInstance.getArg2();
protInstance.getArg3();
pending…

Compare results of other browsers

Revisions

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

0 Comments