Script Preparation code:
x
 
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 = []
for( let i = 0; i < 1000; i++)
{
  a[i] = generateId(16)
  b[i] = generateId(16)
}
Tests:
  • lodash xor

     
    const res = _.xor(a, b)
  • with xor function

     
    function systemicDifference(arr1, arr2){
      const uniqueValues = new Set([...arr1, ...arr2]);
      return Array.from(uniqueValues).filter((value) => !arr1.includes(value) || !arr2.includes(value));
    }
     const res = systemicDifference(a, b)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash xor
    with xor function

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Chrome 114 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
lodash xor 3153.6 Ops/sec
with xor function 182.0 Ops/sec