Tests:
  • temp swap

    x
     
    let arr = [1,4,6]
    let len = arr.length
    let temp  = 0
    for(let i=0; i<Math.floor(arr.length/2); i++){
        
        let x = i
        let y = len-1-i
        
       temp   = arr[x]
       arr[x] = arr[y]
       arr[y] = temp 
        
    }
    console.log(arr)
  • xor swap

     
    let arr = [1,4,6]
    let len = arr.length
    for(let i=0; i<Math.floor(arr.length/2); i++){
        
        let x = i
        let y = len-1-i
        
        arr[x] = arr[x] ^ arr[y]
        arr[y] = arr[x] ^ arr[y]
        arr[x] = arr[x] ^ arr[y]
        
    }
    console.log(arr)
  • inbuilt

     
    let arr= [1,2,3]
    arr.reverse()
  • manual rvers

     
    let arr=[1,2,3], res =[]
    for(let i=arr.length-1; i>=0; i--) {
        res = arr[i]
    }
    console.log(res)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    temp swap
    xor swap
    inbuilt
    manual rvers

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Chrome 106 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
temp swap 123531.7 Ops/sec
xor swap 107936.8 Ops/sec
inbuilt 42128328.0 Ops/sec
manual rvers 169890.8 Ops/sec