Script Preparation code:
AخA
 
arr = Array.from({length: 1000}, (_, i) => i);
Tests:
  • Initial value indexing

     
    const index_zero = arr[0];
    console.log(index_zero);
  • Random value indexing

     
    const index_random = arr[Math.floor(Math.random() * arr.length)];
    console.log(index_random);
  • Last value indexing

     
    const index_last = arr[arr.length - 1];
    console.log(index_last);
  • Initial value at()

     
    const at_zero = arr.at(0);
    console.log(at_zero);
  • Random value at()

     
    const at_random = arr.at(Math.floor(Math.random() * arr.length));
    console.log(at_random);
  • Last value at()

     
    const at_last = arr.at(-1);
    console.log(at_last);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Initial value indexing
    Random value indexing
    Last value indexing
    Initial value at()
    Random value at()
    Last value at()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 12 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Firefox 137 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
Initial value indexing 459557.7 Ops/sec
Random value indexing 440218.0 Ops/sec
Last value indexing 245015.4 Ops/sec
Initial value at() 89233.0 Ops/sec
Random value at() 95650.5 Ops/sec
Last value at() 81549.8 Ops/sec