Script Preparation code:
x
 
// *class* defined in terms of OLOO
var class1 = {
    set_property: function(name, value) {
        this.properties[name] = value;
    },
    get_property: function(name) {
        return this.properties[name];
    },
    get_p: function() {
      return this.p;
    },
    set_p: function(val) {
      this.p = val;
    }
}
function inst_class1() {
    var obj = Object.create(class1)
    obj.properties = {}
    obj.p = 0;
    return obj;
}
// just an object with it's own methods
function inst_class2() {
    return {
        properties: {},
        p: 0,
        set_property: function(name, value) {
            this.properties[name] = value;
        },
        get_property: function(name) {
            return this.properties[name];
        },
        get_p: function() {
           return this.p;
        },
        set_p: function(val) {
          this.p = val;
        }
    }
}
// es6 class
class class3 {
    set_property(name, value) {
        this.properties[name] = value;
    }
    get_property(name) {
        return this.properties[name];
    }
    get_p() {
        return this.p;
    }
    set_p(val) {
        this.p = val;
    }
}
function inst_class3() {
    var obj3 = new class3();
    obj3.properties = {};
    obj3.p = 0;
    return obj3
}
// the test
function test(obj) {
    var result = 0;
    for (var i = 0; i < N; i++) {
        obj.set_property(i, i*0.33);
        result += obj.get_property(i);
        obj.set_p(result);
        result += obj.get_p();
    }
    return result;
}
var N = 1000000;
Tests:
  • oloo

     
    var result = test(inst_class1());
  • direct properties

     
    var result = test(inst_class2());
  • classes

     
    var result = test(inst_class3());
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    oloo
    direct properties
    classes

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.36
Chrome 99 on Windows
View result in a separate tab
Test name Executions per second
oloo 5.9 Ops/sec
direct properties 4.7 Ops/sec
classes 4.7 Ops/sec