Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Find Keys by loop or JSON stringify
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser:
Chrome 136
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
using loop
1738436.6 Ops/sec
using JSON stringify
1048874.8 Ops/sec
Script Preparation code:
var testObject = {}; testObject.eligibilityGroupDates = [{ "id": "8c7969fd-56db-4ed8-9eec-5604c3dceef7", "o2eStartDate": "scrub1", "numOfDaysToCalO2EStartDate": null, "numberOfDaysToEnroll": 99, "eligibilityGroups": ["f32e6a9f-4a4b-4531-af8f-4e4ee0798e91"], "links": [] }, { "id": "7dc6052d-7ede-452a-8425-604c24c3d561", "o2eStartDate": "scrub2", "numOfDaysToCalO2EStartDate": 58, "numberOfDaysToEnroll": 95, "eligibilityGroups": ["f9987b9a-f45a-4131-8528-47242023483e"], "links": [] }, { "id": "af886791-fb79-4d28-921c-539cdaadae79", "o2eStartDate": "scrub2", "numOfDaysToCalO2EStartDate": null, "numberOfDaysToEnroll": 30, "eligibilityGroups": ["927a5c93-368c-4a82-a6d3-99e656624978"], "links": [] }];
Tests:
using loop
if (_.has(testObject, 'eligibilityGroupDates')) { testObject.eligibilityGroupDates.forEach(entry => { Object.keys(entry).forEach(key => { switch (key) { case 'eligibilityGroupDates': _.set(testObject, 'displayEligibilityGroupDates', true); break; case 'o2eStartDate': _.set(testObject, 'displayO2eStartDate', true); break; case 'numOfDaysToCalO2EStartDate': _.set(testObject, 'displayNumOfDaysToCalO2EStartDate', true); break; case 'numberOfDaysToEnroll': _.set(testObject, 'displayNumberOfDaysToEnroll', true); break; default: break; } }); }); }
using JSON stringify
if (_.has(testObject, 'eligibilityGroupDates')) { let value = JSON.stringify(testObject.eligibilityGroupDates); if (value.indexOf('eligibilityGroups') > 0) { _.set(testObject, 'eligibilityGroups', true); } if (value.indexOf('o2eStartDate') > 0) { _.set(testObject, 'displayO2eStartDate', true); } if (value.indexOf('numOfDaysToCalO2EStartDate') > 0) { _.set(testObject, 'displayNumOfDaysToCalO2EStartDate', true); } if (value.indexOf('numberOfDaysToEnroll') > 0) { _.set(testObject, 'displayNumberOfDaysToEnroll', true); } }