{"ScriptPreparationCode":"var test = Array.from(\r\n {\r\n length: 1000000,\r\n },\r\n () =\u003E ({\r\n b: Math.round(Math.random()),\r\n }),\r\n);\r\n\r\nasync function addC(item) {\r\n await new Promise((resolve) =\u003E setTimeout(resolve, 5));\r\n item.c = 9;\r\n return item;\r\n}\r\n\r\nfunction chunk(arr, chunkSize) {\r\n const groups = [];\r\n let i = 0;\r\n while (i \u003C arr.length) {\r\n groups.push(arr.slice(i, (i \u002B= chunkSize)));\r\n }\r\n return groups;\r\n}\r\n\r\nasync function mapOnly(array, size) {\r\n await Promise.all(array.map(async (item) =\u003E await addC(item)));\r\n return array;\r\n}\r\n\r\nasync function chunkAndMap(array, size) {\r\n const chunks = chunk(array, size);\r\n await Promise.all(\r\n chunks.map(async (chunk) =\u003E {\r\n await Promise.all(chunk.map(async (item) =\u003E await addC(item)));\r\n }),\r\n );\r\n return array;\r\n}\r\n\r\nasync function run(fun, arr, chunkSize) {\r\n await fun(arr, chunkSize);\r\n}","TestCases":[{"Name":"Chunk and map 10000","Code":"run(chunkAndMap, test, 10000)","IsDeferred":false},{"Name":"Map only","Code":"run(mapOnly, test, 1000)","IsDeferred":false},{"Name":"Chunk and map 1000","Code":"run(chunkAndMap, test, 1000)","IsDeferred":false},{"Name":"Chunk and map 100","Code":"run(chunkAndMap, test, 100)","IsDeferred":false}]}