Lodash isEqual test

Test on isEqual performance
6 years ago
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36
Test name Executions per second
_.isEqual Level 1 579600.9 Ops/sec
JSON.stringify Level 1 408072.2 Ops/sec
_.isEqual Level 2 362766.7 Ops/sec
JSON.stringify Level 2 394641.1 Ops/sec
_.isEqual Level 3 244585.7 Ops/sec
JSON.stringify Level 3 399713.2 Ops/sec
HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
x
 
// 1 level deep
window.foo1 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
window.bar1 = { a: 1, b: 3, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
// 2 levels deep
window.foo2 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
window.bar2 = { a: 1, b: 2, c: { a: 1, b: 3, c: { a: 1, b: 2 } } };
// 3 levels deep
window.foo3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
window.bar3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 4 } } };
Tests:
  • _.isEqual Level 1

     
    _.isEqual(window.foo1, window.bar1)
  • JSON.stringify Level 1

     
    JSON.stringify(window.foo1) === JSON.stringify(window.bar1);
  • _.isEqual Level 2

     
    _.isEqual(window.foo2, window.bar2)
  • JSON.stringify Level 2

     
    JSON.stringify(window.foo2) === JSON.stringify(window.bar2);
  • _.isEqual Level 3

     
    _.isEqual(window.foo3, window.bar3)
  • JSON.stringify Level 3

     
    JSON.stringify(window.foo3) === JSON.stringify(window.bar3);
Open this result on MeasureThat.net