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:
  • current xor implementation

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

     
     var as = new Set(a)
     var bs = new Set(b)
     const res = a
        .filter((row_id) => bs.has(row_id))
        .concat(b.filter((row_id) => !as.has(row_id)))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    current xor implementation
    alternative with Sets

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 16 days ago)
Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0
Firefox 137 on Linux
View result in a separate tab
Test name Executions per second
current xor implementation 1053.6 Ops/sec
alternative with Sets 6459.0 Ops/sec