Merge branch 'master' into feature/task-functions
[poolifier.git] / benchmarks / versus-external-pools / fixed-workerpool.mjs
index c55291945515e0bb0391db472e5ea5e5e3c16547..9e016331ed86cd7d6f8a308b87c8e6d0b28fc135 100644 (file)
@@ -1,6 +1,6 @@
-// IMPORT LIBRARIES
 import workerpool from 'workerpool'
-// FINISH IMPORT LIBRARIES
+import { executeAsyncFn } from './utils.mjs'
+
 const size = parseInt(process.env.POOL_SIZE)
 const iterations = parseInt(process.env.NUM_ITERATIONS)
 const dataArray = [
@@ -19,13 +19,13 @@ const workerPool = workerpool.pool(
 )
 
 async function run () {
-  const promises = []
+  const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.push(workerPool.exec('functionToBench', dataArray))
+    promises.add(workerPool.exec('functionToBench', dataArray))
   }
   await Promise.all(promises)
   // eslint-disable-next-line n/no-process-exit
   process.exit()
 }
 
-await run()
+await executeAsyncFn(run)