Script Preparation code:
x
 
var sorted = new Array(200000);
var shuffled = new Array(200000);
class Vector { 
    constructor() {
      this.x = 0;
      this.y = 0;
      this.z = 0;
    }
}
for (let i=0; i<200000; i++) {
  const obj = { position: new Vector(), scale: new Vector(), rotation: new Vector() };
  sorted[i] = obj;
  shuffled[i] = obj;
}
for (let i=0; i<200000; i++) {
  const index = Math.floor(Math.random() * 200000);
  const temp = shuffled[i];
  shuffled[i] = shuffled[index];
  shuffled[index] = temp;
}
Tests:
  • Shuffled

     
    for (let i=0; i<200000; i++) {
        const obj = shuffled[i];
        if (obj.position.x === 0 && obj.position.y === 0 && obj.position.z === 0) {}
    }
  • Shuffled const

     
    for (let i=0; i<200000; i++) {
        const obj = shuffled[i];
        const position = obj.position;
        if (position.x === 0 && position.y === 0 && position.z === 0) {}
    }
  • Sorted

     
    for (let i=0; i<200000; i++) {
        const obj = sorted[i];
        if (obj.position.x === 0 && obj.position.y === 0 && obj.position.z === 0) {}
    }
  • Sorted const

     
    for (let i=0; i<200000; i++) {
        const obj = sorted[i];
        const position = obj.position;
        if (position.x === 0 && position.y === 0 && position.z === 0) {}
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Shuffled
    Shuffled const
    Sorted
    Sorted const

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119 on Windows
View result in a separate tab
Test name Executions per second
Shuffled 25.0 Ops/sec
Shuffled const 25.9 Ops/sec
Sorted 67.9 Ops/sec
Sorted const 69.0 Ops/sec