Object vs. Variables Access

Benchmark created by Ash Blue on


Description

Test variable access of object access vs regular access.

Test runner

Ready to run.

Testing in
TestOps/sec
Simple Variable
var x = 50;
var y = 50;

var test = x + y;
ready
Simple Object
var size = {
  x: 50,
  y: 50
};

var test = size.x + size.y;
ready
Mixed Variable
var size = {
  calculate: function () {
    var x = 50;
    var y = 50

    return x + y;
  }
};

size.calculate();
ready
Mixed Object
var size = {
  x: 50,
  y: 50,
  calculate: function () {
    return this.x + this.y;
  }
};

size.calculate();
ready

Revisions

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