test speed objects

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
ob1
function A() {
  var p1 = 1;

  function privateFunction() {
    p1 = 2;
  }

  this.v = 'prop +';

  this.publicFunction = function() {
    privateFunction(); // private are visible
    alert(this.v + p1); // access to public with "this."
  }
}

A.prototype.AA1 = function(t){alert(this.v+t)};
var arr = [];
for (var i = 0; i < 10000; i++) {
  arr[i] = new A();
}
for (var i = 0; i < 10000; i++) {
  arr[i].publicFunction();
  arr[i].AA1('t-');
}
ready
ob2
var A = function() {
    var p1 = 1;

    function privateFunction() {
      p1 = 2;
    }

    function B() {
      return 1;
    }

    B.prototype.v = 'prop +';

    B.prototype.publicFunction = function() {
      privateFunction(); // private are visible
      alert(this.v + p1); // access to public with "this."
    }
    return B;
}
   
A.prototype.AA1 = function(t){alert(this.v+t)}; 
var arr = [];
for (var i = 0; i < 10000; i++) {
  arr[i] = new(A())();
}
for (var i = 0; i < 10000; i++) {
  arr[i].publicFunction();
  arr[i].AA1('t-');
}
ready

Revisions

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