{"ScriptPreparationCode":"// Generate an array with 100 objects\r\nvar rawData = [];\r\nfor (let i = 0; i \u003C 5001; i\u002B\u002B) {\r\n rawData.push({\r\n cost_per: Math.random() * 100,\r\n network: \u0060network${i}\u0060,\r\n metric: {\r\n name: \u0060metric${i}\u0060,\r\n description: \u0060Description ${i}\u0060,\r\n },\r\n created_at: \u00602023-09-01T00:00:00-07:00\u0060,\r\n });\r\n}\r\n\r\n// Using a Map for indexing\r\nvar transformedDataMap = new Map();\r\n\r\nfor (const entry of rawData) {\r\n const key = JSON.stringify({\r\n network: entry.network,\r\n metricName: entry.metric.name,\r\n createdAt: entry.created_at,\r\n });\r\n transformedDataMap.set(key, entry.cost_per);\r\n}","TestCases":[{"Name":"Test using Map for indexing (5000 iterations)","Code":"\r\nconst iterations = 5000;\r\nconst mapLookupKey = JSON.stringify({\r\n network: \u0027network50\u0027,\r\n metricName: \u0027metric50\u0027,\r\n createdAt: \u00272023-09-01T00:00:00-07:00\u0027,\r\n});\r\nfor (let i = 0; i \u003C iterations; i\u002B\u002B) {\r\n const mapResult = transformedDataMap.get(mapLookupKey);\r\n}","IsDeferred":false},{"Name":"Test using Array.prototype.find (5000 iterations)","Code":"\r\nconst iterations = 5000;\r\nconst arrayLookupKey = {\r\n network: \u0027network50\u0027,\r\n metricName: \u0027metric50\u0027,\r\n createdAt: \u00272023-09-01T00:00:00-07:00\u0027,\r\n};\r\nconst arrayStartTime = new Date().getTime();\r\nfor (let i = 0; i \u003C iterations; i\u002B\u002B) {\r\n const arrayResult = rawData.find((entry) =\u003E {\r\n return (\r\n entry.network === arrayLookupKey.network \u0026\u0026\r\n entry.metric.name === arrayLookupKey.metricName \u0026\u0026\r\n entry.created_at === arrayLookupKey.createdAt\r\n );\r\n });\r\n}","IsDeferred":false}]}