Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Compare objects
(version: 0)
Comparing performance of:
JSON.stringify vs _.isEqual
Created:
7 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
var defaultConfig = { searchTerms: { jobType: '', search: '', fromDate: '', toDate: '', }, transactionCount: '1', transactions: [ { accountId: '5854154987', date: '2019-03-25', wkn: 'aasdfsdafas', isin: 'asdfsfsa', fundName: 'asdfdasfasdf', jobType: 'asdfdsfs', orderType: 'asdf', amount: '546541321', isAmountCalculated: false, units: '1.192', owner: 'asdfs asdfasf', accountNumber: 'asdfdsf', blz: 'asdfsdf', bic: 'asdfasdfasd', iban: 'asdfdsafas', creator: 'asdfdsfas', timeline: { capture: { isRelevant: true, date: '2019-03-25', }, deadline: { isRelevant: false, }, booking: { isRelevant: false, }, received: { isRelevant: true, date: '2019-03-26', time: '14:00:00', }, priceFix: { isRelevant: true, date: '2019-03-27', }, posting: { isRelevant: true, date: '2019-03-28', }, visibleOnline: { isRelevant: true, date: '2019-03-29', }, directDebitCollection: { isRelevant: true, date: '2019-03-27', }, outgoingPayments: { isRelevant: false, }, }, investmentCompany: 'asdfdsafasfsa', status: 'asdfsafsaf', discount: 'n.v.', transactionId: '6576541321', }, { accountId: '7864132156', date: '2019-03-25', wkn: '46532132489', isin: 'asdfdsafsa', fundName: 'asdfasdfa', jobType: 'asdfsafs', orderType: 'asdfdasfas', amount: '1.000,00', isAmountCalculated: false, units: '1.192', owner: 'asdfdasfsa', accountNumber: '1001537380', blz: '50021100', bic: 'asdfdasfas', iban: 'asdfasfas', creator: 'asdfasdfas', timeline: { capture: { isRelevant: true, date: '2019-03-25', }, deadline: { isRelevant: false, }, booking: { isRelevant: false, }, received: { isRelevant: true, date: '2019-03-26', time: '14:00:00', }, priceFix: { isRelevant: true, date: '2019-03-27', }, posting: { isRelevant: true, date: '2019-03-25', }, visibleOnline: { isRelevant: true, date: '2019-03-29', }, directDebitCollection: { isRelevant: true, date: '2019-03-27', }, outgoingPayments: { isRelevant: false, }, }, investmentCompany: 'asdfdasfasdfas', status: 'asdfasdfas', discount: 'n.v.', transactionId: '64765146574', }, ], };
Tests:
JSON.stringify
JSON.stringify(defaultConfig.transactions[0]) === JSON.stringify(defaultConfig.transactions[1])
_.isEqual
_.isEqual(defaultConfig.transactions[0], defaultConfig.transactions[1])
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
JSON.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):
Let's break down the benchmark and its test cases. **Benchmark Definition JSON** The provided JSON represents a benchmark definition for measuring the performance of two different approaches to comparing objects: `JSON.stringify` and `_.isEqual`. The benchmark uses a predefined configuration object `defaultConfig`, which contains an array of transactions. The goal is to compare two identical transaction objects using these two methods. **Script Preparation Code** The script preparation code sets up the `defaultConfig` object, which includes various properties such as search terms, transaction count, and individual transactions. Each transaction has similar properties like account ID, date, WKN (Weltliche Zahlentragungsnummer), ISIN (International Securities Identification Number), fund name, job type, order type, amount, etc. **Html Preparation Code** The HTML preparation code includes a script tag that loads the Lodash library, specifically version 4.17.4. The `_.isEqual` function is used in one of the benchmark test cases to compare two objects. **Individual Test Cases** There are two individual test cases: 1. **JSON.stringify**: This test case compares the string representation of two identical transaction objects using the `JSON.stringify` method. 2. **_.isEqual**: This test case uses the Lodash library's `_.isEqual` function to compare two identical transaction objects. **Comparing Options** The benchmark tests two different approaches: 1. **JSON.stringify**: This approach converts the entire object graph into a string and then compares the strings using the `===` operator. 2. **_.isEqual**: This approach uses the Lodash library's `_.isEqual` function, which recursively checks for deep equality between objects. **Pros and Cons** Here are some pros and cons of each approach: * **JSON.stringify**: + Pros: Simple to implement, widely supported by browsers. + Cons: Can be slow and resource-intensive, especially for large object graphs. * **_.isEqual**: + Pros: More efficient than `JSON.stringify`, especially for deep equality checks. + Cons: Requires the Lodash library, which may not be necessary in all cases. **Latest Benchmark Result** The latest benchmark result shows that: * The **_.isEqual** approach outperforms the **JSON.stringify** approach with an average of 818598 executions per second compared to 165414 executions per second. * Both approaches are executed at a rate of approximately 165,000 times per second in the given browser configuration. Overall, the benchmark suggests that using `_.isEqual` can provide better performance and efficiency when comparing objects, especially for larger object graphs or deep equality checks.
Related benchmarks:
_.sortBy vs native sort
testing performance for dates
dsdsdsdsdsdsds
Non insensitive sorting
Comments
Confirm delete:
Do you really want to delete benchmark?