immutable merge vs object assign

JavaScript performance comparison

Test case created by

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.1/immutable.min.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  const objA = {
    aze: { bze: 'bze' },
    bze: { aze: 'aze' },
    position: {
      pp: {
        posH: null,
        posV: null
      }
    }
  }
  
  const objB = {
    bze: { aze: 'nope' },
    position: {
      pp: {
        posH: 501,
        posV: 502,
        posZ: 444
      },
      items: [1, 2, 3]
    }
  }
  
  const objAImmutable = Immutable.fromJS(objA)
  const objBImmutable = Immutable.fromJS(objB)

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Object.assign
const objC = Object.assign({}, objA, objB)
pending…
Immutable.merge
const objC = objAImmutable.merge(objBImmutable)
pending…

Revisions

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

0 Comments