Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash vs deepmerge vs deepmerge-ts vs ts-deepmerge
(version: 0)
Comparing performance of:
lodash vs deepmerge vs deepmerge-ts vs ts-deepmerge
Created:
2 years ago
by:
Guest
Jump to the latest result
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'; import { merge as tsDeepmerge } from 'https://unpkg.com/ts-deepmerge@7.0.0/esm/index.js'; window.deepmergeTs = deepmerge; window.tsDeepmerge = tsDeepmerge; </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>
Run tests (4)
Previous results
Fork
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
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash
102898.3 Ops/sec
deepmerge
333326.0 Ops/sec
deepmerge-ts
219152.6 Ops/sec
ts-deepmerge
482655.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the explanation of the benchmark. **Benchmark Overview** The benchmark compares the performance of four JavaScript libraries: Lodash, DeepMerge, DeepMerge-ts, and Ts-DeepMerge. The test cases are designed to merge two objects together, which is a common operation in JavaScript development. **Options Compared** The options compared are: 1. **Lodash**: A popular JavaScript utility library that provides a wide range of functions for various tasks, including object manipulation. 2. **DeepMerge**: A lightweight library specifically designed for merging objects recursively. 3. **DeepMerge-ts**: A TypeScript version of DeepMerge, which is compiled to JavaScript and compatible with the language's type system. 4. **Ts-DeepMerge**: Another TypeScript version of DeepMerge, which is also compiled to JavaScript. **Pros and Cons** Here are some pros and cons of each library: 1. **Lodash**: * Pros: Wide range of functions, high performance, easy integration with other libraries. * Cons: Large bundle size (around 240KB), may be overkill for simple tasks. 2. **DeepMerge**: * Pros: Lightweight (around 10KB), fast, and efficient. * Cons: Limited functionality compared to Lodash, may not support all edge cases. 3. **DeepMerge-ts**: * Pros: TypeScript compatibility, type safety, and compile-time checks. * Cons: Smaller usage base compared to Lodash or DeepMerge. 4. **Ts-DeepMerge**: * Pros: Similar functionality to DeepMerge-ts, with a smaller bundle size (around 20KB). * Cons: Less well-known than DeepMerge-ts. **Test Cases** The benchmark consists of four test cases, each merging two objects together: 1. Two simple objects with basic properties. 2. Two complex objects with nested arrays and objects. 3. Two objects with duplicate keys. Each test case is executed 235,644 times (the number of executions per second), which provides a reasonable estimate of performance under heavy load. **Benchmark Results** The latest benchmark results show that: 1. **Ts-DeepMerge** performs the best, with an average of 51,556 executions per second. 2. **DeepMerge** is a close second, averaging around 25,391 executions per second. 3. **DeepMerge-ts** and **Lodash** trail behind, averaging around 9,650 and 8,643 executions per second, respectively. These results indicate that DeepMerge and Ts-DeepMerge are the most efficient options for merging objects in JavaScript, while Lodash may be overkill due to its large bundle size.
Related benchmarks:
lodash merge vs deepmerge.all
lodash merge vs deepmerge latest CDN
lodash vs deepmerge vs deepmerge-ts
My lodash vs deepmerge vs deepmerge-ts
Comments
Confirm delete:
Do you really want to delete benchmark?