{"ScriptPreparationCode":"function getRandomElement(id) {\r\n return {\r\n id,\r\n a: Math.random(),\r\n b: Math.random(),\r\n c: Math.random(),\r\n }\r\n}\r\n\r\nfunction getArray(length) {\r\n const result = [];\r\n for (let i = 0; i \u003C length; i\u002B\u002B) {\r\n result.push(getRandomElement(i))\r\n }\r\n \r\n return result;\r\n}\r\n\r\nfunction arrayToMap(array) {\r\n return new Map(array.map(el =\u003E [el.id, el]));\r\n}\r\n\r\nfunction getRandomInt(max) {\r\n return Math.floor(Math.random() * max);\r\n}\r\n\r\narray_small = getArray(2);\r\narray_large = getArray(5);\r\n\r\nmap_small = arrayToMap(array_small);\r\nmap_large = arrayToMap(array_large);","TestCases":[{"Name":"Array.find, 10 000 elements","Code":"const target = getRandomInt(3);\r\narray_small.find(el =\u003E el.id === target);","IsDeferred":false},{"Name":"Map.get, 10 000 elements","Code":"const target = getRandomInt(3);\r\nmap_small.get(target);","IsDeferred":false},{"Name":"Array.find, 1 000 000 elements ","Code":"const target = getRandomInt(6);\r\narray_large.find(el =\u003E el.id === target);","IsDeferred":false},{"Name":"Map.get, 1 000 000 elements","Code":"const target = getRandomInt(6);\r\nmap_large.get(target)","IsDeferred":false},{"Name":"Array to Map \u002B Map.get, 1 lookup","Code":"const map = arrayToMap(array_small);\r\nconst target = getRandomInt(3);\r\nmap.get(target);","IsDeferred":false},{"Name":"Array to Map \u002B Map.get, 10 lookups","Code":"const map = arrayToMap(array_small);\r\n\r\nfor (let i = 0; i \u003C 10; i\u002B\u002B) {\r\n const target = getRandomInt(3);\r\n map.get(target);\r\n}","IsDeferred":false},{"Name":"Array to Map \u002B Map.get, 100 lookups","Code":"const map = arrayToMap(array_small);\r\n\r\nfor (let i = 0; i \u003C 100; i\u002B\u002B) {\r\n const target = getRandomInt(3);\r\n map.get(target);\r\n}","IsDeferred":false},{"Name":"Array.find, 10 lookups","Code":"for (let i = 0; i \u003C 10; i\u002B\u002B) {\r\n const target = getRandomInt(3);\r\n array_small.find(el =\u003E el.id === target)\r\n}","IsDeferred":false},{"Name":"Array.find, 100 lookups","Code":"for (let i = 0; i \u003C 100; i\u002B\u002B) {\r\n const target = getRandomInt(3);\r\n array_small.find(el =\u003E el.id === target)\r\n}","IsDeferred":false}]}