Script Preparation code:
AخA
 
var arr = [...Array(10000)].map((_,i) => i)
Tests:
  • unshift

     
    arr.forEach((v,i) => {
    console.log(v,i);
    arr.unshift(arr.splice(i,1).shift())
    })
  • swapping

     
    arr.sort((a,b) => (a === b) ? 0 : (a < b) ? 1 : -1)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    unshift
    swapping

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Mobile Safari/537.36
Chrome Mobile 134 on Android
View result in a separate tab
Test name Executions per second
unshift 6.4 Ops/sec
swapping 5666.4 Ops/sec