lodash vs deepmerge vs deepmerge-ts
Date tested:
one year ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 Firefox/103.0
Test name
Executions per second
lodash
119355.9 Ops/sec
deepmerge
279353.0 Ops/sec
deepmerge-ts
187732.0 Ops/sec
Benchmark definition (click to collapse):
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.6.2/lodash.min.js'></script> <script src='https://unpkg.com/deepmerge@4.2.2/dist/umd.js'></script> <script type="module"> import { deepmerge } from 'https://unpkg.com/deepmerge-ts@4.2.1/dist/node/index.mjs'; window.deepmergeTs = deepmerge; </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 = 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 = deepmergeTs({}, x, y);
Open this result on MeasureThat.net