Script Preparation code:
x
 
var objs = [];
var proxProp = [];
var proxDyn = [];
var proxEval = [];
var proxFunc = [];
var count = 1000;
var a, b, c;
class ProxProp {
    constructor(data) { this.data = data }
    get a() { return this.data.a; }
    get b() { return this.data.b; }
    get c() { return this.data.c; }
    set a(v) { this.data.a = v; }
    set b(v) { this.data.b = v; }
    set c(v) { this.data.c = v; }
}
const ProxEval = eval(`class ProxEval {
    constructor(data) { this.data = data }
    get a() { return this.data.a; }
    get b() { return this.data.b; }
    get c() { return this.data.c; }
    set a(v) { this.data.a = v; }
    set b(v) { this.data.b = v; }
    set c(v) { this.data.c = v; }
};
ProxEval;
`);
const ProxFunc = new Function(`return class ProxFunc {
    constructor(data) { this.data = data }
    get a() { return this.data.a; }
    get b() { return this.data.b; }
    get c() { return this.data.c; }
    set a(v) { this.data.a = v; }
    set b(v) { this.data.b = v; }
    set c(v) { this.data.c = v; }
};
`);
class ProxDyn {
    constructor(data) { this.data = data }
}
["a", "b", "c"].forEach(n=> Object.defineProperty(ProxDyn.prototype, n, {
    get() { return this.data[n]; },
    set(v) { this.data[n] = v; },
}));
for (let i = 0; i < count; i++) {
    const obj = { a: Math.random(), b: new Date, c: Date.now().toString() };
    objs.push(obj);
    proxProp.push(new ProxProp(obj));
    proxDyn.push(new ProxDyn(obj));
    proxEval.push(new ProxEval(obj));
    proxFunc.push(new ProxFunc(obj));
}
Tests:
  • Get generated property with eval

     
    for (let i = 0; i < proxEval.length; i++) {
        const obj = proxEval[i];
        a = obj.a;
        b = obj.b;
        c = obj.c;
    }
  • Get property

     
    for (let i = 0; i < proxProp.length; i++) {
        const obj = proxProp[i];
        a = obj.a;
        b = obj.b;
        c = obj.c;
    }
  • Get dynamic property

     
    for (let i = 0; i < proxDyn.length; i++) {
        const obj = proxDyn[i];
        a = obj.a;
        b = obj.b;
        c = obj.c;
    }
  • Get field

     
    for (let i = 0; i < objs.length; i++) {
        const obj = objs[i];
        a = obj.a;
        b = obj.b;
        c = obj.c;
    }
  • Nothing

     
    for (let i = 0; i < objs.length; i++) {
        const obj = objs[i];
    }
  • Get generated property with Function ctor

     
    for (let i = 0; i < proxFunc.length; i++) {
        const obj = proxFunc[i];
        a = obj.a;
        b = obj.b;
        c = obj.c;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Get generated property with eval
    Get property
    Get dynamic property
    Get field
    Nothing
    Get generated property with Function ctor

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Safari/605.1.15
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Get generated property with eval 3741.8 Ops/sec
Get property 3745.4 Ops/sec
Get dynamic property 3721.2 Ops/sec
Get field 3787.8 Ops/sec
Nothing 12450.9 Ops/sec
Get generated property with Function ctor 3806.3 Ops/sec