Script Preparation code:
x
 
class Basic {
  obj = {};
  add(k, v) {
    this.obj[k] = v;
  }
  getValues() {
    return Object.values(this.obj);
  }
};
class Cached {
  obj = {};
  cache = [];
  add(k, v) {
    this.obj[k] = this.cache.length;
    this.cache.push(v);
  }
  getValues() {
    return this.cache;
  }
};
basic = new Basic();
cached = new Cached();
for (let i = 0; i < 1000; i++) {
  basic.add('a' + i, i);
  cached.add('a' + i, i);
}
Tests:
  • Fetch vias Object.values()

     
    basic.getValues()
  • Fetch via cached array

     
    cached.getValues()
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Fetch vias Object.values()
    Fetch via cached array

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1.1 Mobile/15E148 Safari/604.1
Mobile Safari 17 on iOS 17.1.1
View result in a separate tab
Test name Executions per second
Fetch vias Object.values() 105617.7 Ops/sec
Fetch via cached array 9609163.0 Ops/sec