HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.6.2/lodash.min.js'></script>
2
<script src='https://unpkg.com/deepmerge@4.2.2/dist/umd.js'></script>
3
<script type="module">
4
import { deepmerge } from 'https://unpkg.com/deepmerge-ts@4.2.1/dist/node/index.mjs';
5
import { merge as tsDeepmerge } from 'https://unpkg.com/ts-deepmerge@7.0.0/esm/index.js';
6
window.deepmergeTs = deepmerge;
7
window.tsDeepmerge = tsDeepmerge;
8
</script>
Tests:
  • lodash

     
    var a = { a: 'oh', b: 'my', c: { a: 'a', b: { c: 'c' } } };
    var b = { c: { b: { d: 'a'  }, c: { d: 'd' } } };
    var c = _.merge({}, a, b);
    const x = {
        foo: { bar: 3 },
        array: [{
            does: 'work',
            too: [ 1, 2, 3 ]
        }]
    }
     
    const y = {
        foo: { baz: 4 },
        quux: 5,
        array: [{
            does: 'work',
            too: [ 4, 5, 6 ]
        }, {
            really: 'yes'
        }]
    }
    var z = _.merge({}, x, y);
  • deepmerge

     
    var a = { a: 'oh', b: 'my', c: { a: 'a', b: { c: 'c' } } };
    var b = { c: { b: { d: 'a'  }, c: { d: 'd' } } };
    var c = deepmerge({}, a, b);
    const x = {
        foo: { bar: 3 },
        array: [{
            does: 'work',
            too: [ 1, 2, 3 ]
        }]
    }
     
    const y = {
        foo: { baz: 4 },
        quux: 5,
        array: [{
            does: 'work',
            too: [ 4, 5, 6 ]
        }, {
            really: 'yes'
        }]
    }
    var z = deepmerge({}, x, y);
  • deepmerge-ts

     
    var a = { a: 'oh', b: 'my', c: { a: 'a', b: { c: 'c' } } };
    var b = { c: { b: { d: 'a'  }, c: { d: 'd' } } };
    var c = deepmergeTs({}, a, b);
    const x = {
        foo: { bar: 3 },
        array: [{
            does: 'work',
            too: [ 1, 2, 3 ]
        }]
    }
     
    const y = {
        foo: { baz: 4 },
        quux: 5,
        array: [{
            does: 'work',
            too: [ 4, 5, 6 ]
        }, {
            really: 'yes'
        }]
    }
    var z = deepmergeTs({}, x, y);
  • ts-deepmerge

     
    var a = { a: 'oh', b: 'my', c: { a: 'a', b: { c: 'c' } } };
    var b = { c: { b: { d: 'a'  }, c: { d: 'd' } } };
    var c = tsDeepmerge({}, a, b);
    const x = {
        foo: { bar: 3 },
        array: [{
            does: 'work',
            too: [ 1, 2, 3 ]
        }]
    }
     
    const y = {
        foo: { baz: 4 },
        quux: 5,
        array: [{
            does: 'work',
            too: [ 4, 5, 6 ]
        }, {
            really: 'yes'
        }]
    }
    var z = tsDeepmerge({}, x, y);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash
    deepmerge
    deepmerge-ts
    ts-deepmerge

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Chrome 124 on Windows
View result in a separate tab
Test name Executions per second
lodash 51656.7 Ops/sec
deepmerge 125391.1 Ops/sec
deepmerge-ts 96850.1 Ops/sec
ts-deepmerge 235644.9 Ops/sec