HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js'></script>
3
<script src='https://cdn.jsdelivr.net/npm/deepmerge@4.2.2/dist/cjs.min.js'></script>
Tests:
  • lodash merge

     
    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);
  • deepmerge

     
    const combineMerge = (target, source, options) => {
        const destination = target.slice()
        source.forEach((item, index) => {
            if (typeof destination[index] === 'undefined') {
                destination[index] = options.cloneUnlessOtherwiseSpecified(item, options)
            } else if (options.isMergeableObject(item)) {
                destination[index] = merge(target[index], item, options)
            } else if (target.indexOf(item) === -1) {
                destination.push(item)
            }
        })
        return destination
    }
    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, { arrayMerge: combineMerge });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash merge
    deepmerge

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 16 hours ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Chrome 135 on Windows
View result in a separate tab
Test name Executions per second
lodash merge 541750.8 Ops/sec
deepmerge 280756.6 Ops/sec