Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Big array: Lodash vs. Set Intersection vs Loop with Set
(version: 1)
Comparing performance of:
Javascript Set intersection vs Lodash intersection vs Loop with Set
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var first = new Array(1000).fill().map((_,a) => a); var second = first.slice(900);
Tests:
Javascript Set intersection
const firstSet = new Set(first); const secondSet = new Set(second); new Set([...firstSet].filter(item => secondSet.has(item)));
Lodash intersection
_.intersection(first, second)
Loop with Set
const firstSet = new Set(first); second.filter(item => firstSet.has(item));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Javascript Set intersection
Lodash intersection
Loop with Set
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/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Javascript Set intersection
65012.0 Ops/sec
Lodash intersection
24291.1 Ops/sec
Loop with Set
111217.5 Ops/sec
Related benchmarks:
Lodash vs. Set Intersection
Lodash vs Javascript Set Intersection
Lodash vs. Set Intersection v2
Lodash vs. Set Intersection (1000000)
Lodash vs. Set Intersection Test Drive
Array vs. Set Intersection
Array vs. Set Intersection #2
Lodash vs. Set Methods Intersection
Lodash vs. Set Intersection vs Loop with Set
Comments
Confirm delete:
Do you really want to delete benchmark?