Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash deepMerge vs Object.assign
Compare Lodash deepMerge vs Object.assign
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash
34.5 Ops/sec
Native
39.4 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var max = 100000; var arr = []; for (var i = 0; i <= max; i++) { arr.push(i); }
Tests:
Lodash
arr.forEach(() => { let object = { 'a': { 'b': 2 } }; let other = { 'a': { 'b': 1, 'c': 3 } }; _.defaultsDeep(object, other); })
Native
function defaultsDeep(target, ...sources) { sources.forEach(source => { Object.keys(source).forEach(key => { if (typeof source[key] === 'object') { if (!target[key]) { Object.assign(target, { [key]: {} }); } defaultsDeep(target[key], source[key]); } else { if (!target[key]) { Object.assign(target, { [key]: source[key] }); } } }); }); return target; } arr.forEach(() => { let object = { 'a': { 'b': 2 } }; let other = { 'a': { 'b': 1, 'c': 3 } }; defaultsDeep(object, other); });