Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash.isEqual vs fast-deep-equal (only arrays)
(version: 1)
Comparing performance of:
lodash vs fast-deep-equal
Created:
10 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js"></script>
Script Preparation code:
function equal(a, b) { if (a === b) return true; if (a && b && typeof a == 'object' && typeof b == 'object') { if (a.constructor !== b.constructor) return false; var length, i, keys; if (Array.isArray(a)) { length = a.length; if (length != b.length) return false; for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false; return true; } if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); keys = Object.keys(a); length = keys.length; if (length !== Object.keys(b).length) return false; for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; for (i = length; i-- !== 0;) { var key = keys[i]; if (!equal(a[key], b[key])) return false; } return true; } // true if both NaN, false otherwise return a !== a && b !== b; }; // 1 level deep var data = [ { description: 'empty arrays', value1: [], value2: [], equal: true, }, { description: 'different length arrays', value1: [1, 2, 3], value2: [1, 2], equal: false, }, { description: 'arrays with different types', value1: [1, 2, 3], value2: ['1', '2', '3'], equal: false, }, { description: 'arrays with null/undefined', value1: [1, null, 3], value2: [1, undefined, 3], equal: false, }, { description: 'arrays with NaN', value1: [1, NaN, 3], value2: [1, NaN, 3], equal: true, }, { description: 'large number arrays', value1: Array.from({ length: 10000 }, (_, i) => i), value2: Array.from({ length: 10000 }, (_, i) => i), equal: true, }, { description: 'large string arrays', value1: Array.from({ length: 1000 }, (_, i) => `string${i}`), value2: Array.from({ length: 1000 }, (_, i) => `string${i}`), equal: true, }, { description: 'mixed primitive arrays', value1: [1, 'hello', true, null, undefined, NaN], value2: [1, 'hello', true, null, undefined, NaN], equal: true, }, { description: 'sparse arrays', value1: [1, , 3], value2: [1, undefined, 3], equal: false, }, { description: 'arrays with special numbers', value1: [0, -0, Infinity, -Infinity], value2: [0, -0, Infinity, -Infinity], equal: true, }, ];
Tests:
lodash
data.forEach((item) => { _.isEqual(item.value1, item.value2); });
fast-deep-equal
data.forEach((item) => { equal(item.value1, item.value2); });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash
fast-deep-equal
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0
Browser/OS:
Chrome 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash
11382.7 Ops/sec
fast-deep-equal
18077.8 Ops/sec
Related benchmarks:
lodash.isEqual vs fast-deep-equal
lodash deepEqual vs fast-deep-equal v2
lodash.isEqual vs fast-deep-equal vs local
lodash.isEqual vs dequal 2
lodash vs fast-deep-equal using fast-deep-equal's tests
lodash.isEqual vs fast-deep-equal SHALLOW
lodash vs fast-equals vs fast-deep-equal
lodash.isEqual vs fast-deep-equal 2
lodash.isEqual vs fast-deep-equal vs local 2
Comments
Confirm delete:
Do you really want to delete benchmark?