Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash difference vs Set
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash
1925677.4 Ops/sec
Set
1954832.8 Ops/sec
HTML Preparation code:
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js"></script>
Script Preparation code:
const currentSubscriberIds = ['user1', 'user2', 'user3', 'user4', 'user5']; const newSubscriberIds = ['user3', 'user4', 'user5', 'user6', 'user7'];
Tests:
Lodash
const subscribersToAdd = _.difference(newSubscriberIds, currentSubscriberIds); const subscribersToRemove = _.difference(currentSubscriberIds, newSubscriberIds);
Set
const currentSubscribersSet = new Set(currentSubscriberIds); const newSubscribersSet = new Set(newSubscriberIds); const subscribersToAddSet = [...new Set(newSubscriberIds)] .filter(id => !currentSubscribersSet.has(id)); // ['user6', 'user7'] const subscribersToRemoveSet = [...currentSubscribersSet] .filter(id => !newSubscribersSet.has(id)); // ['user1', 'user2']