Script Preparation code:
AخA
 
var tests = 100,
    ct = 100000,
    arr = [];
for (var i = 0; i < ct; i++) {
  arr[i] = Math.floor(Math.random() * ct) + 1;
}
Tests:
  • Splice

     
    for (var i = tests; i--;) {
      var from = Math.floor(Math.random() * ct) + 1,
          to = Math.floor(Math.random() * ct) + 1,
          fromArr = arr.splice(from, 1);
      arr.splice(to, 0, fromArr[0]);
    }
  • Temp

     
    for (var i = tests; i--;) {
      var from = Math.floor(Math.random() * ct) + 1,
          to = Math.floor(Math.random() * ct) + 1,
          tmp = arr[from];
      arr[from] = arr[to];
      arr[to] = tmp;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Splice
    Temp

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Chrome 53 on Windows
View result in a separate tab
Test name Executions per second
Splice 172.1 Ops/sec
Temp 4299.3 Ops/sec