Script Preparation code:
AخA
 
function randomArray(e) {    
    e = e || 32;
    var t = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",
    a = t.length,
    n = [];
    for (i = 0; i < e; i++) n.push(t.charAt(Math.floor(Math.random() * a)));
    return n
}
var arr1 = randomArray(100)
var arr2 = randomArray(10000)
var arr3 = randomArray(1000000)
Tests:
  • splice-1

     
    var result1 = arr1.splice(Math.floor(arr1.length / 2), 1, "i")
  • splice-2

     
    var result1 = arr2.splice(Math.floor(arr2.length / 2), 1, "i")
  • splice-3

     
    var result1 = arr3.splice(Math.floor(arr3.length / 2), 1, "i")
  • toSpliced-1

     
    var result1 = arr1.toSpliced(Math.floor(arr1.length / 2), 1, "i")
  • toSpliced-2

     
    var result1 = arr2.toSpliced(Math.floor(arr2.length / 2), 1, "i")
  • toSpliced-3

     
    var result1 = arr3.toSpliced(Math.floor(arr3.length / 2), 1, "i")
  • splice-3 add items

     
    var result1 = arr3.splice(Math.floor(arr3.length / 2), 1, "i", "2")
  • splice-3 remove

     
    var result1 = arr3.splice(Math.floor(arr3.length / 2), 1)
  • toSpliced-3 add

     
    var result1 = arr3.toSpliced(Math.floor(arr3.length / 2), 1, "i", "d")
  • toSpliced-3 remove

     
    var result1 = arr3.toSpliced(Math.floor(arr3.length / 2), 1)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    splice-1
    splice-2
    splice-3
    toSpliced-1
    toSpliced-2
    toSpliced-3
    splice-3 add items
    splice-3 remove
    toSpliced-3 add
    toSpliced-3 remove

    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/120.0.0.0 Safari/537.36
Chrome 120 on Windows
View result in a separate tab
Test name Executions per second
splice-1 3758490.8 Ops/sec
splice-2 3618269.8 Ops/sec
splice-3 3762439.5 Ops/sec
toSpliced-1 3089284.2 Ops/sec
toSpliced-2 194754.6 Ops/sec
toSpliced-3 448.6 Ops/sec
splice-3 add items 1251.2 Ops/sec
splice-3 remove 1758.3 Ops/sec
toSpliced-3 add 460.7 Ops/sec
toSpliced-3 remove 453.0 Ops/sec