Direct property access vs getter function (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  var foo = {
   bar: 5,
   getBar: function() {
    return this.bar;
   }
  };

  var foo2 = {
   get bar() { return foo2._bar; },
  _bar : 5    
   };

var Foo3 = function(){this._bar = 5;};

    Object.defineProperty(Foo3.prototype, "bar", {
        get: function () {
            return this._bar;
        },
        enumerable: true,
        configurable: true
    });
var foo3 = new Foo3();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Direct
foo.bar;
ready
Getter function
foo.getBar();
ready
Getter;
foo2.bar;
ready
Property (ES5)
foo3.bar;
ready

Revisions

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