Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash Custom Merge
(version: 0)
Comparing performance of:
Lodash vs Me
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
function themeMerge(target, source) { function isObject(item) { return item && typeof item === 'object' && !Array.isArray(item) } let output = Object.assign({}, target) if (isObject(target) && isObject(source)) { Object.keys(source).forEach(key => { if (isObject(source[key])) { if (!(key in target)) Object.assign(output, { [key]: source[key] }) else output[key] = themeMerge(target[key], source[key]) } else { Object.assign(output, { [key]: source[key] }) } }) } return output }
Tests:
Lodash
var a = { a: 'oh', b: 'my' }; var b = { c: 'goddess' }; var c = _.merge(a, b);
Me
var a = { a: 'oh', b: 'my' }; var b = { c: 'goddess' }; var c = themeMerge(a, b);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
Me
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/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
13564371.0 Ops/sec
Me
13933069.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The provided benchmark definition json represents the Lodash Custom Merge test case, which compares two approaches: using the popular library Lodash for merging objects. **What is being tested?** The benchmark tests the performance of two functions: 1. `themeMerge`: a custom implementation of object merge by the user (you). 2. `lodash.merge`: a built-in function from the Lodash library, which is often used to merge objects. The benchmark measures the execution speed of each function in creating and merging objects with nested properties. **Options compared** Two options are being compared: 1. **Custom implementation (`themeMerge`)**: The user's custom implementation of object merge. 2. **Lodash `merge`**: A built-in function from the Lodash library that performs object merge. **Pros and Cons of each approach** **Custom implementation (`themeMerge`)** Pros: * Allows for fine-grained control over the merge process. * Can be optimized for specific use cases or performance requirements. Cons: * May require more code and complexity compared to using a built-in library like Lodash. * Errors can occur due to incorrect implementation. **Lodash `merge`** Pros: * Provides a well-tested and widely adopted solution for object merging. * Reduces the likelihood of errors due to its maturity and extensive testing. Cons: * May have performance overhead or additional dependencies compared to a custom implementation. **Other considerations** * **Library usage**: The benchmark uses Lodash as a library, which is a popular choice for its versatility and extensive set of functions. Using a library can simplify development but may add dependencies. * **Special JS feature**: There are no special JavaScript features or syntax used in this benchmark definition. It only relies on standard JavaScript object merge techniques. **Alternatives** Other alternatives to Lodash `merge` include: 1. **Underscore.js`: Another popular JavaScript library that provides a similar set of utility functions, including `merge`. 2. **Built-in `Object.assign()`**: A simple and lightweight approach to merging objects using the built-in `Object.assign()` method. 3. **Custom implementation without libraries**: Developing a custom object merge function from scratch, without relying on libraries like Lodash or Underscore.js. Keep in mind that these alternatives may have different performance characteristics or trade-offs compared to using Lodash `merge`.
Related benchmarks:
Merge list of objects
lodash merge vs spread operator
Array Properties Merge: Lodash merge vs Object.assign
saddasdasadasdasd
asasddasasdasd
Comments
Confirm delete:
Do you really want to delete benchmark?