Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
My lodash vs deepmerge vs deepmerge-ts
(version: 0)
Comparing performance of:
lodash vs deepmerge vs deepmerge-ts
Created:
one year 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'; 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);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
lodash
deepmerge
deepmerge-ts
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser/OS:
Chrome 129 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash
227577.8 Ops/sec
deepmerge
263234.4 Ops/sec
deepmerge-ts
433567.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what is being tested. **Benchmark Overview** The benchmark measures the performance of three different libraries: Lodash, DeepMerge, and DeepMerge-ts, which are used to merge objects in JavaScript. The test case involves creating two objects, `a` and `b`, with nested structures, and then merging them using each library to produce a third object, `z`. **Tested Options** The benchmark compares the performance of three options: 1. **Lodash**: Lodash is a popular utility library for JavaScript that provides a wide range of functions for working with data, including object manipulation. 2. **DeepMerge**: DeepMerge is a lightweight library specifically designed for merging objects in JavaScript. It aims to be fast and efficient while also being easy to use. 3. **DeepMerge-ts**: DeepMerge-ts is the TypeScript version of DeepMerge, which provides type safety benefits for developers working with TypeScript. **Pros and Cons** Here are some pros and cons of each option: * **Lodash**: + Pros: Lodash has a large community of users and contributors, making it well-maintained and widely supported. It also provides a wide range of utility functions beyond object merging. + Cons: Lodash can be heavy-handed in its approach to function creation, which may lead to slower performance compared to specialized libraries like DeepMerge. * **DeepMerge**: + Pros: DeepMerge is designed specifically for object merging and is lightweight, making it well-suited for performance-critical applications. It also has a simple and easy-to-use API. + Cons: DeepMerge is relatively new and may not have the same level of community support as Lodash. * **DeepMerge-ts**: + Pros: As the TypeScript version of DeepMerge, DeepMerge-ts provides type safety benefits for developers working with TypeScript. It also inherits the performance benefits of its JavaScript counterpart. + Cons: Since it's a new library, there may not be as much community support or resources available compared to Lodash. **Library and Purpose** * **Lodash**: A utility library that provides a wide range of functions for working with data, including object manipulation. Its purpose is to provide a comprehensive set of functions for tasks such as array manipulation, string manipulation, and more. * **DeepMerge**: A lightweight library specifically designed for merging objects in JavaScript. Its purpose is to provide an efficient and easy-to-use way to merge objects, which can be useful in performance-critical applications. **Special JS Feature or Syntax** There are no special JS features or syntaxes used in this benchmark. However, it's worth noting that DeepMerge-ts uses TypeScript's type system to ensure type safety benefits for developers working with TypeScript. **Alternatives** If you're looking for alternatives to these libraries, here are a few options: * **Immer**: A library for immutably updating objects in JavaScript. While not specifically designed for merging objects, it can be used as an alternative. * **Objectassign**: A built-in JavaScript function for creating a new object by copying properties from one or more source objects. While not as efficient as DeepMerge, Objectassign is a lightweight alternative. * **Loose Equals**: Another lightweight library for merging objects in JavaScript.
Related benchmarks:
lodash merge vs deepmerge latest CDN
lodash merge vs deepmerge vs ramda merge
lodash vs deepmerge vs deepmerge-ts
lodash vs deepmerge vs deepmerge-ts vs ts-deepmerge
Comments
Confirm delete:
Do you really want to delete benchmark?