Prototype Operator Performance

JavaScript performance comparison

Revision 4 of this test case created by

Preparation code

<script>
  var i;
  var A, A_instance;
  var B, B_instance;
  var C, C_instance;

function _m(s) { var msg = s + ''; };
function _a(i, j) { return (i * 2 + j * 2) / 2; };

  A = function() {
    this.message = _m(s);
    this.addition = _a(i, j);
  };
  A_instance = new A();

  B = function() {};
  B.prototype.message = function(s) {
    var msg = s + '';
  };
  B.prototype.addition = function(i, j) {
    return (i * 2 + j * 2) / 2;
  };
  B_instance = new B();

  C = function() {
    C.prototype.message = _m(s);
    C.prototype.addition = _a(i, j);
  };
  C_instance = new C();
</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
A method is declared into class
A_instance.message('Hi');
A_instance.addition(i, 2);
pending…
B method is declared outside class by using protoype keyword
_m('Hi')
_a(i, 2)
pending…
C method is declared into class by using protoype keyword
C_instance.message('Hi');
C_instance.addition(i, 2);
pending…
Create A instance and run methods
A_instance = new A();
A_instance.message('Hi');
A_instance.addition(i, 2);
pending…
Create B instance and run methods
B_instance = new B();
B_instance.message('Hi');
B_instance.addition(i, 2);
pending…
Create C instance and run methods
C_instance = new C();
C_instance.message('Hi');
C_instance.addition(i, 2);
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