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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Browser:
Chrome 118
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.filter
2450.4 Ops/sec
Array.splice
3390.5 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;