Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
splice VS filter: filtering big list of elements
100k list
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0
Browser:
Firefox 143
Operating system:
Linux
Device Platform:
Desktop
Date tested:
7 months ago
Test name
Executions per second
filter
5.8 Ops/sec
splice
7.6 Ops/sec
Script Preparation code:
var list = []; var filterOutList = [10, 100, 1000, 50000, 50100, 50200, 50300, 99999] for (var i = 0; i < 1000 * 1000; i++) { list.push(i); }
Tests:
filter
list = list.filter((el) => !filterOutList.includes(el))
splice
let i = 0 while(i < list.length) { if (filterOutList.includes(list[i])) { list.splice(i, 1) continue } i++ }