Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Set.difference vs Filter + includes
(version: 1)
Comparing performance of:
Sets vs Arrays
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const array1 = Array.from({length: 100}, () => Math.floor(Math.random() * 140)); const array2 = Array.from({length: 100}, () => Math.floor(Math.random() * 140));
Tests:
Sets
const set1 = new Set(array1); const set2 = new Set(array2); set1.difference(set2);
Arrays
array1.filter((id) => !array2.includes(id));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Sets
Arrays
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser/OS:
Chrome 132 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Sets
344491.9 Ops/sec
Arrays
697001.1 Ops/sec
Related benchmarks:
Set vs Filter for unique
Set vs Filter for unique vs for
Set vs Filter vs includes+push for unique
Diff size Set vs Filter for unique
Set from array vs array Filter unique
Set vs Good Filter for unique
Set vs Filter vs forEach for unique
Set vs Filter vs forEach vs forLoop for unique
Array Diffs
Comments
Confirm delete:
Do you really want to delete benchmark?