Merge branch 'master' into feature/task-functions
[poolifier.git] / benchmarks / versus-external-pools / fixed-poolifier.mjs
index aa922be8a9928651519572177eeb728cb9fe72b3..5efd786e562d1d6acabe2ad2981ccd2754fbe42e 100644 (file)
@@ -1,6 +1,6 @@
-// IMPORT LIBRARIES
 import { FixedThreadPool } from 'poolifier'
-// FINISH IMPORT LIBRARIES
+import { executeAsyncFn } from './utils.mjs'
+
 const size = parseInt(process.env.POOL_SIZE)
 const iterations = parseInt(process.env.NUM_ITERATIONS)
 const data = {
@@ -9,19 +9,22 @@ const data = {
   taskSize: parseInt(process.env.TASK_SIZE)
 }
 
-const fixedPool = new FixedThreadPool(
+const fixedThreadPool = new FixedThreadPool(
   size,
-  './workers/poolifier/function-to-bench-worker.mjs'
+  './workers/poolifier/function-to-bench-worker.mjs',
+  {
+    enableTasksQueue: false
+  }
 )
 
 async function run () {
-  const promises = []
+  const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.push(fixedPool.execute(data))
+    promises.add(fixedThreadPool.execute(data))
   }
   await Promise.all(promises)
   // eslint-disable-next-line n/no-process-exit
   process.exit()
 }
 
-await run()
+await executeAsyncFn(run)