Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Splice vs Filter 2
(version: 1)
Comparing performance of:
Splice vs Filter
Created:
7 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
const arr = Array(500).fill(0).map(() => Math.floor(Math.random() * 1000000));
Tests:
Splice
const num = arr[Math.floor(Math.random() * 500)] const index = arr.find(item => item === num) if (index > -1) { arr.splice(index, 1) } arr.push(1)
Filter
const num = arr[Math.floor(Math.random() * 500)] const newArr = arr.filter(item => item !== num) newArr.push(1)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Splice
Filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Splice
21031.9 Ops/sec
Filter
76.2 Ops/sec
Related benchmarks:
Slice, splice, and filter
FindIndex + splice vs filter
Remove an item from array; indexOf + splice vs filter
Remove an item from array; indexOf + splice vs filter 2
Slice vs splice vs filter
FindIndex + splice vs filter (fixed, slice array before splicing)
rzegtytreh
JS filter vs splice +indexOf
FindIndex(real findIndex) + splice vs filter
Comments
Confirm delete:
Do you really want to delete benchmark?