Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
swap with splice vs spread
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
splice
8.8 Ops/sec
spread
8.2 Ops/sec
Script Preparation code:
var array = []; var length = 1000000 for(var i = 0; i < length; i++){array.push(Math.random());}
Tests:
splice
for(let i = 0; i < array.length-1; i++){array.splice(i,2,array[i+1],array[i]);}
spread
for(let i = 0; i < array.length-1; i++){[array[i+1],array[i]]=[array[i],array[i+1]]}