immutable.js redux state updates

Benchmark created on


Preparation HTML

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

Setup

const MOCK_ENTITY = {
    id: 'ec6865e6-e60e-424b-a071-6a9c1603d735',
    type: { namespace: 'NAMESPACE', name: 'NAME' },
    description: 'description',
    properties: [
      '0c8be4b7-0bd5-4dd1-a623-da78871c9d0e',
      '4b08e1f9-4a00-4169-92ea-10e377070220',
      '8f79e123-3411-4099-a41f-88e5d22d0e8d',
      'e39dfdfa-a3e6-4f1f-b54b-646a723c3085',
      'fae6af98-2675-45bd-9a5b-1619a87235a8'
    ],
  };
  
  const state = Immutable.fromJS(MOCK_ENTITY);

Test runner

Ready to run.

Testing in
TestOps/sec
set single
state.set('id', 'some_entity_id');
ready
merge single
state.merge({
  'id': 'some_entity_id'
});
ready
set multiple
state
  .set('id', 'some_entity_id')
  .set('type', Immutable.fromJS({ namespace: 'A', name: 'B' }))
  .set('properties', Immutable.fromJS([
    'some_property_id'
  ]));
ready
merge multiple
state.merge({
  'id': 'some_entity_id',
  'type': Immutable.fromJS({ namespace: 'A', name: 'B' }),
  'properties': Immutable.fromJS([
    'some_property_id'
  ])
});
ready

Revisions

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