Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JavaScript spread operator vs Slice/Splice performance - 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15
Browser:
Safari 16
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Array clone with spread operator
20.4M/s
Array clone with slice
17.6M/s
Array addition with spread operator
10.5M/s
Array addition with slice and push
9.2M/s
View exact numbers
Test name
Executions per second
✓
Array clone with spread operator
20,380,324 Ops/sec
Array clone with slice
17,643,202 Ops/sec
Array addition with spread operator
10,528,340 Ops/sec
Array addition with slice and push
9,247,208 Ops/sec
Script Preparation code:
const ITERATIONS = 500000; var index = ITERATIONS/2; var n = Math.random(); var list = []; for (let i = 0; i < length; i += 1) { list.push(Math.random()); }
Tests:
Array clone with spread operator
const clone = [...list];
Array clone with slice
const clone = list.slice();
Array addition with spread operator
const clone = [...list, n];
Array addition with slice and push
const clone = list.slice(); clone.push(n);