Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.filter vs Array.splice
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/144.0.0.0 Safari/537.36
Browser:
Chrome 144
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
Array.filter
22542.6 Ops/sec
Array.splice
515028.9 Ops/sec
Script Preparation code:
const array = Array.from({length: 10_000}, () => Math.floor(Math.random() * 10_000_000)); const indexToDelete = 7500; const deleteCount = 500;
Tests:
Array.filter
const temp = [...array]; return temp.filter((x, i) => i < indexToDelete || i >= indexToDelete + deleteCount);
Array.splice
const temp = [...array]; temp.splice(indexToDelete, deleteCount); return temp;