Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Stringify vs Lodash Deep Comparison Performance
(version: 0)
JSON.stringify vs lodash's isEqual
Comparing performance of:
stringify vs isEqual
Created:
3 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash.isequal@4.5.0/index.js"></script>
Script Preparation code:
const a = { bids: [ [41634.5, 0.0], [41641.0, 600000.0], [42285.0, 0.0], [42291.5, 300000.0], [42504.5, 60000.0], [42507.5, 0.0], [42719.0, 0.0], [42719.5, 470742.0], [42725.5, 225000.0], [42734.0, 0.0], [43066.0, 0.0], [43072.5, 225000.0], [43153.0, 0.0], [43153.5, 233493.0], [43159.5, 225000.0], [43167.5, 1998005.0], [43168.0, 0.0], [43168.5, 0.0], [43171.5, 0.0], [43239.0, 80000.0], [43269.5, 250000.0], [43270.5, 0.0], [43285.0, 199.0], [43287.5, 1977.0], [43288.5, 0.0], [43295.5, 0.0], [43327.5, 59340.0], [43333.5, 0.0], [43335.0, 0.0], [43338.5, 20000.0], [43343.5, 10000.0], ], asks: [ [43379.0, 10000.0], [43383.0, 10000.0], [43403.0, 78676.0], [43403.5, 23218.0], [43404.0, 0.0], [43406.5, 450.0], [43427.0, 2086.0], [43430.5, 117604.0], [43431.0, 20000.0], [43437.5, 199999.0], [43445.0, 0.0], [43446.0, 19616.0], [43506.5, 0.0], [43507.0, 140114.0], [43531.0, 0.0], [43593.5, 0.0], [43594.0, 225000.0], [43680.5, 0.0], [43681.0, 300000.0], [43896.5, 485213.0], [43897.0, 0.0], [43897.5, 300000.0], [43911.0, 0.0], [44461.5, 0.0], [44462.0, 400000.0], [45111.0, 0.0], [45112.5, 600000.0], ] } const b = { bids: [ [41634.5, 0.0], [41641.0, 600000.0], [42285.0, 0.0], [42291.5, 300000.0], [42504.5, 60000.0], [42507.5, 0.0], [42719.0, 0.0], [42719.5, 470742.0], [42725.5, 225000.0], [42734.0, 0.0], [43066.0, 0.0], [43072.5, 225000.0], [43153.0, 0.0], [43153.5, 233493.0], [43159.5, 225000.0], [43167.5, 1998005.0], [43168.0, 0.0], [43168.5, 0.0], [43171.5, 0.0], [43239.0, 80000.0], [43269.5, 250000.0], [43270.5, 0.0], [43285.0, 199.0], [43287.5, 1977.0], [43288.5, 0.0], [43295.5, 0.0], [43327.5, 59340.0], [43333.5, 0.0], [43335.0, 0.0], [43338.5, 20000.0], [43343.5, 10000.0], ], asks: [ [43379.0, 10000.0], [43383.0, 10000.0], [43403.0, 78676.0], [43403.5, 23218.0], [43404.0, 0.0], [43406.5, 450.0], [43427.0, 2086.0], [43430.5, 117604.0], [43431.0, 20000.0], [43437.5, 199999.0], [43445.0, 0.0], [43446.0, 19616.0], [43506.5, 0.0], [43507.0, 140114.0], [43531.0, 0.0], [43593.5, 0.0], [43594.0, 225000.0], [43680.5, 0.0], [43681.0, 300000.0], [43896.5, 485213.0], [43897.0, 0.0], [43897.5, 300000.0], [43911.0, 0.0], [44461.5, 0.0], [44462.0, 400000.0], [45111.0, 0.0], [45112.5, 600000.0], ] }
Tests:
stringify
JSON.stringify(window.a) === JSON.stringify(window.b);
isEqual
_.isEqual(window.a, window.b)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
stringify
isEqual
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The issue is likely that the `window` object is not defined in the test environment, causing the `JSON.stringify(window.a)` and `_.isEqual(window.a, window.b)` expressions to fail. To fix this, you can modify the test code to use a local variable instead of `window`. For example: ```javascript a = [...]; // initialize a with some data b = [...]; // initialize b with some data if (JSON.stringify(a) === JSON.stringify(b)) { console.log('stringify passed'); } _.isEqual(a, b); ``` Alternatively, if you're using a testing framework like Jest or Mocha, you can define the `window` object as part of your test setup. For example: ```javascript describe('Benchmark tests', () => { beforeEach(() => { window = { a: [...], b: [...] }; // define window object here }); it('stringify passes', () => { if (JSON.stringify(window.a) === JSON.stringify(window.b)) { console.log('stringify passed'); } }); it('isEqual passes', () => { _.isEqual(window.a, window.b); }); }); ``` This way, the `window` object is defined in the test environment, and the tests should run without issues.
Related benchmarks:
lodash omit versus spread omit
Lodash union VS ES6 Set
uniqBy performance lodash vs native
JS Deep Comparison Performance
Comments
Confirm delete:
Do you really want to delete benchmark?