Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash "unionBy" test
(version: 0)
Comparing performance of:
unionBy vs test
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js'></script>
Script Preparation code:
var users = [ { 'name': 'barney', 'age': 36 }, ]; var newUsers = [ { 'name': 'fred', 'age': 40 }, { 'name': 'barney', 'age': 36 }, { 'name': 'pebbles', 'age': 2 } ]; for(let i = 0; i < 2000; i++) { var newUser = { 'name': 'user_' + i, 'age': Math.floor(Math.random() * i) }; newUsers.push(newUser); users.push(newUser) }
Tests:
unionBy
const unionUsers2 = _.unionBy(newUsers, users, 'name'); console.log('ub', unionUsers2.length)
test
let obj = {} users.forEach((user) => obj[user.name] = user) newUsers.forEach((user) => obj[user.name] = user) console.log('test', Object.values(obj).length)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
unionBy
test
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
unionBy
7171.2 Ops/sec
test
6221.0 Ops/sec
Related benchmarks:
Map lodash and PureJS
lodash assign vs spread operator properly
A native map vs lodash _.map
lodash assign vs spread operator 2
native find vs lodash _.find for objects equality
Comments
Confirm delete:
Do you really want to delete benchmark?