Merge branch 'master' into feature/task-functions
[poolifier.git] / benchmarks / versus-external-pools / dynamic-tinypool.mjs
index acb8627f4f1e2f4ca1592d8aaa29b9f21a6d6160..77b5d1114a613522174713751586b1e347e9af8b 100644 (file)
@@ -1,6 +1,6 @@
-// IMPORT LIBRARIES
 import Tinypool from 'tinypool'
-// FINISH IMPORT LIBRARIES
+import { executeAsyncFn } from '../benchmarks-utils.mjs'
+
 const size = parseInt(process.env.POOL_SIZE)
 const iterations = parseInt(process.env.NUM_ITERATIONS)
 const data = {
@@ -17,13 +17,13 @@ const tinypool = new Tinypool({
 })
 
 async function run () {
-  const promises = []
+  const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.push(tinypool.run(data))
+    promises.add(tinypool.run(data))
   }
   await Promise.all(promises)
   // eslint-disable-next-line n/no-process-exit
   process.exit()
 }
 
-await run()
+await executeAsyncFn(run)