Immutable multiple set vs merge vs mergeDeep

Benchmark created by JuanJo Tugores on


Preparation HTML

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

Setup

const { Map, List } = Immutable;
  
  
  const a = Map({
    a: 'a',
    b: 'b',
    c: 'c',
    d: 'd',
    e: 'f',
    g: 'g',
    h: 'h',
    i: 'i',
    j: 'j',
    k: 'k',
    l: 'l',
    m: 'm',
    n: 'o',
    p: 'q',
    r: 'r',
    s: 's',
    t: 't',
    u: 'u',
    v: 'v',
    w: 'w',
    x: 'x',
    y: 'y',
    z: 'z'
  });

Test runner

Ready to run.

Testing in
TestOps/sec
set
const b = a.set('a', 1)
           .set('c', 2)
           .set('f', 3)
           .set('g', 4)
           .set('v', 5)
           .set('z', 6)
           .set('add', '7')
           .set('more', '8');
ready
merge
const b = a.merge({
a:1,
c:2,
f:3,
g:4,
v:5,
z:6,
add: '7',
more: '8'
})
ready
mergeDeep
const b = a.mergeDeep({
a:1,
c:2,
f:3,
g:4,
v:5,
z:6,
add: '7',
more: '8'
})
ready

Revisions

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

  • Revision 1: published by JuanJo Tugores on