Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash xor performance with multiple arrays
(version: 1)
Searching for faster solution for _.xor(a, b)
Comparing performance of:
lodash xor vs with Sets
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
function dec2hex (dec) { return dec < 10 ? '0' + String(dec) : dec.toString(16) } function generateId (len) { var arr = new Uint8Array((len || 40) / 2) window.crypto.getRandomValues(arr) return Array.from(arr, dec2hex).join('') } var a = [] var b = [] var c = [] var d = [] var e = [] var f = [] var g = [] for( let i = 0; i < 1000; i++) { a[i] = generateId(16) b[i] = generateId(16) c[i] = generateId(16) d[i] = generateId(16) e[i] = generateId(16) f[i] = generateId(16) g[i] = generateId(16) }
Tests:
lodash xor
const res = _.xor(a, b, c, d, e, f, g)
with Sets
function xor(...arrays) { const allItems = new Map(); arrays.forEach(array => { const localSet = new Set(array); localSet.forEach(item => { const count = allItems.get(item) || 0; allItems.set(item, count + 1); }); }); return Array.from(allItems.entries()) .filter(([item, count]) => count === 1) .map(([item]) => item); } const res = xor(a, b, c, d, e, f, g)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash xor
with Sets
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/134.0.0.0 Safari/537.36
Browser/OS:
Chrome 134 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash xor
346.1 Ops/sec
with Sets
1307.7 Ops/sec
Related benchmarks:
lodash xor alternatives
lodash xor perf
lodash xor perf v2
lodash xor alternatives (copy)
lodash xor alternatives Copy 2
lodash xor alternatives Copy 3
lodash xor perf copy
lodash xor / sets / includes perf
array diff (lodash difference / sets / includes) perf
Comments
Confirm delete:
Do you really want to delete benchmark?