HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.2/immutable.min.js"></script>
2
<script src="https://cdn.jsdelivr.net/npm/immutability-helper@2.7.0/index.min.js"></script>
Tests:
  • Immutable.Set union

    x
     
    const set1_Immutable = new Immutable.Set(Array.from(Array(100).keys()));
    const set2_Immutable = new Immutable.Set(Array.from(Array(1000).keys()));
    const result = set1_Immutable.union(set2_Immutable)
  • Convert JS Set to array, construct new Set

     
    const set1_JS = new Set(Array.from(Array(100).keys()));
    const set2_JS = new Set(Array.from(Array(1000).keys()));
    const result = new Set([...set1_JS, ...set2_JS])
  • Array.from, construct new Set

     
    const set1_JS = new Set(Array.from(Array(100).keys()));
    const set2_JS = new Set(Array.from(Array(1000).keys()));
    const result = new Set(Array.from(set1_JS).concat(Array.from(set2_JS)))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Immutable.Set union
    Convert JS Set to array, construct new Set
    Array.from, construct new Set

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Chrome 135 on Windows
View result in a separate tab
Test name Executions per second
Immutable.Set union 10014.9 Ops/sec
Convert JS Set to array, construct new Set 19342.0 Ops/sec
Array.from, construct new Set 20631.1 Ops/sec