Immutable Union (v3)

Revision 3 of this benchmark created on


Description

Comparing solutions offered at http://stackoverflow.com/questions/30126698/how-to-get-union-of-several-immutable-js-lists

Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.7.6/immutable.min.js"></script>

Setup

var a = Immutable.List([1, 4]);
    var b = Immutable.List([2, 3, 4]);

Test runner

Ready to run.

Testing in
TestOps/sec
Union ala Travis J
function union(left,right){
 var union = {};
 left.forEach(function(x){
  union[x] = undefined;
 });
 right.forEach(function(x){
  union[x] = undefined;
 });
 return Immutable.List(Object.keys(union).map(function(i){ return parseInt(i,10); }));
}

var c = union(a,b);
 
ready
Immutable toSet().union()
var c = a.toSet().union(b.toSet()).toList(); 
ready
Immutable toSet().union() w/o secondary toSet()
var c = a.toSet().union(b).toList(); 
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.