Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Combine "set with destructuring" vs "map with push"
(version: 0)
Comparing performance of:
set with destructuring vs map with push
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
set with destructuring
const teachers = [{id: 'A'}, {id: 'B'}, {id: 'C'}, {id: 'F'}, {id: 'H'}, {id: 'I'}]; const admins = [{id: 'A'}, {id: 'C'}, {id: 'D'}, {id: 'E'}, {id: 'F'}, {id: 'G'}]; const ids = new Set(teachers.map(item => item.id)); const merged = [...teachers, ...admins.filter(item => !ids.has(item.id))];
map with push
const users = [{id: 'A'}, {id: 'B'}, {id: 'C'}, {id: 'F'}, {id: 'H'}, {id: 'I'}]; const addendUsers = [{id: 'A'}, {id: 'C'}, {id: 'D'}, {id: 'E'}, {id: 'F'}, {id: 'G'}]; const combinedUsersMap = {}; const combinedUsers = []; users.forEach(user => { if (!combinedUsersMap[user.id]) { combinedUsersMap[user.id] = true; combinedUsers.push(user); } }); addendUsers.forEach(addendUser => { if (!combinedUsersMap[addendUser.id]) { combinedUsersMap[addendUser.id] = true; combinedUsers.push(addendUser); } });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
set with destructuring
map with push
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Array from() vs Map.keys() vs Map.values() vs spread
Array from() vs Map.keys() vs Map.values() vs spread (fixed)
Array.from() vs new Array() + destruct
{} vs Object.create vs new Set vs new Map vs new WeakSet vs new WeakMap
new Map vs set array to map
Comments
Confirm delete:
Do you really want to delete benchmark?