Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
`Array.slice(0, N)` vs `Array.length = N`
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/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
`Array.slice(0, N)`
58.2M/s
`Array.length = N`
50.1M/s
`Object.assign([], arr)` with `Array.length = N`
884K/s
View exact numbers
Test name
Executions per second
✓
`Array.slice(0, N)`
58,170,336 Ops/sec
`Array.length = N`
50,082,004 Ops/sec
`Object.assign([], arr)` with `Array.length = N`
883,758 Ops/sec
Script Preparation code:
var arr = Array.from(Array(100).keys());
Tests:
`Array.slice(0, N)`
arr.slice(0, 20);
`Array.length = N`
arr.length = 20;
`Object.assign([], arr)` with `Array.length = N`
var newArr = Object.assign([], arr); newArr.length = 20;