Create Read Write Patterns

Benchmark created by qnotemedia on


Test runner

Ready to run.

Testing in
TestOps/sec
Prototype
Class1 = (function() {

  this._foo = 'foo';
  this._bar = 'bar';

  function Class1() {};

  return Class1;
})();

Class1.prototype.getFoo = function() {
  return this._foo;
};
Class1.prototype.setFoo = function(param) {
  this._foo = param;
};
Class1.prototype.getBar = function() {
  return this._bar;
};
Class1.prototype.setBar = function(param) {
  this._bar = param;
};

var test1 = new Class1();
ready
Singleton
(function(app, undefined) {
  var _foo = 'foo';
  var _bar = 'bar';

  app.getFoo = function() {
    return _foo;
  };
  app.setFoo = function(param) {
    _foo = param;
  };

  app.getBar = function() {
    return _bar;
  };
  app.setBar = function(param) {
    _bar = param;
  };
})(Class2 = window.Class2 || {});
ready
Named with prototype
function Class3() {
  var _foo = 'foo';
  var _bar = 'bar';

  return this;
};

Class3.prototype.getFoo = function() {
  return this._foo;
};
Class3.prototype.setFoo = function(param) {
  this._foo = param;
};
Class3.prototype.getBar = function() {
  return this._bar;
};
Class3.prototype.setBar = function(param) {
  this._bar = param;
};

var test3 = new Class3();
ready
Named with return
function Class4() {
  var _foo = 'foo';
  var _bar = 'bar';

  function initApp() {}

  initApp();

  return {
    getFoo: function() {
      return _foo;
    },
    setFoo: function(param) {
      _foo = param;
    },
    getBar: function() {
      return _bar;
    },
    setBar: function(param) {
      _bar = param;
    }
  }
};

var test1 = new Class4();
ready

Revisions

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

  • Revision 1: published by qnotemedia on