Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.entries(CERTIFICATES_MAP)
(version: 0)
Object.entries(CERTIFICATES_MAP)
Comparing performance of:
sadsadsadsa vs 12312321321
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
Test
Tests:
sadsadsadsa
const CERTIFICATES_MAP = { hasTCC: 'tccElite', hasTCE: 'tceElite', hasTCF: 'tcfElite', hasTCS: 'tcsElite', }; const EMPTY_CERTIFICATES = { hasTCF: false, hasTCS: false, hasTCC: false, hasTCE: false, }; const data = [ { "id": 14444, "name": "iso28000", "isActive": true, "certificationDate": "2020-10-25T08:00:00.000Z", "expirationDate": "2021-10-21T09:50:00.000Z" }, { "id": 14446, "name": "tccElite", "isActive": true, "certificationDate": "2020-10-25T08:00:00.000Z", "expirationDate": "2021-10-21T09:50:00.000Z" }, { "id": 14448, "name": "tcsElite", "isActive": true, "certificationDate": "2020-10-25T08:00:00.000Z", "expirationDate": "2021-10-21T09:50:00.000Z" }, { "id": 16343, "name": "tcfElite", "isActive": true, "certificationDate": "2021-11-10T00:00:00.000Z", "expirationDate": "2022-11-10T00:00:00.000Z" }, { "id": 16344, "name": "auditedInsurance", "isActive": true, "certificationDate": "2021-11-10T00:00:00.000Z", "expirationDate": "2022-11-10T00:00:00.000Z" } ]; Object.entries(CERTIFICATES_MAP).reduce((certificates, [k, v]) => { const cert = data.find( ({ name }) => name === v); certificates[k] = cert && cert.isActive || false; return certificates; }, {});
12312321321
const CERTIFICATES_MAP = { hasTCC: 'tccElite', hasTCE: 'tceElite', hasTCF: 'tcfElite', hasTCS: 'tcsElite', }; const EMPTY_CERTIFICATES = { hasTCF: false, hasTCS: false, hasTCC: false, hasTCE: false, }; const data = [ { "id": 14444, "name": "iso28000", "isActive": true, "certificationDate": "2020-10-25T08:00:00.000Z", "expirationDate": "2021-10-21T09:50:00.000Z" }, { "id": 14446, "name": "tccElite", "isActive": true, "certificationDate": "2020-10-25T08:00:00.000Z", "expirationDate": "2021-10-21T09:50:00.000Z" }, { "id": 14448, "name": "tcsElite", "isActive": true, "certificationDate": "2020-10-25T08:00:00.000Z", "expirationDate": "2021-10-21T09:50:00.000Z" }, { "id": 16343, "name": "tcfElite", "isActive": true, "certificationDate": "2021-11-10T00:00:00.000Z", "expirationDate": "2022-11-10T00:00:00.000Z" }, { "id": 16344, "name": "auditedInsurance", "isActive": true, "certificationDate": "2021-11-10T00:00:00.000Z", "expirationDate": "2022-11-10T00:00:00.000Z" } ]; Object.entries(CERTIFICATES_MAP).reduce((previousVal, currentKey) => { const certifications = { ...previousVal }; certifications[currentKey] = !!data.find( ({ name }) => name === CERTIFICATES_MAP[currentKey]); return certifications; }, {});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
sadsadsadsa
12312321321
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 provided benchmark and explain what's being tested, compared, and their pros and cons. **Benchmark Overview** The benchmark measures the performance of JavaScript's `Object.entries()` method in combination with various approaches to iterate over an object's properties and values. The test cases are designed to evaluate the efficiency of different methods for filtering certificates based on a predefined map. **Test Cases** There are two test cases: 1. **Case 1**: `Object.entries(CERTIFICATES_MAP).reduce((certificates, [k, v]) => { ... }, {})` * This test case uses the `reduce()` method to iterate over the object's entries and create a new object with filtered certificates. 2. **Case 2**: `Object.entries(CERTIFICATES_MAP).reduce((previousVal, currentKey) => { ... }, {})` * This test case uses the same `reduce()` method but with a different key generation approach. **Comparison** The benchmark compares the performance of these two approaches: 1. **Method 1 (Case 1)**: Uses `Object.entries()` to get an array of key-value pairs, then iterates over it using `reduce()`. 2. **Method 2 (Case 2)**: Uses `Object.entries()` to get an array of key-value pairs and directly iterates over the key generation expression. **Pros and Cons** * **Method 1 (Case 1)** + Pros: - Easier to understand and maintain. - More concise code. + Cons: - May be slower due to the additional iteration step. * **Method 2 (Case 2)** + Pros: - Potentially faster, as it avoids an extra iteration. - Can be more efficient for large objects. + Cons: - More complex and harder to understand. - May require more careful error handling. **Current Benchmark Results** The latest benchmark results show that: * Case 1 (Method 1) performs better than Case 2 (Method 2). * Both cases perform well, with an average of around 857705 executions per second on the specified machine. Keep in mind that these results may vary depending on your specific environment and JavaScript engine.
Related benchmarks:
map vs fromentries 2
Compare check existing on Object / Set / Map
keys VS map
object.keys map vs for in
Object.entries VS Object.keys with obj[key]
Comments
Confirm delete:
Do you really want to delete benchmark?