build(deps-dev): apply updates
[poolifier.git] / benchmarks / benchmarks-utils.js
index aaf7521ff3044807e02078c2cde0f45c584586b1..678b41d7634e56254c3cfb660738aea2cf8ee20d 100644 (file)
@@ -64,7 +64,7 @@ const runPoolifierPool = async (pool, { taskExecutions, workerData }) => {
           if (executions === taskExecutions) {
             resolve({ ok: 1 })
           }
-          return null
+          return undefined
         })
         .catch(err => {
           console.error(err)
@@ -76,12 +76,15 @@ const runPoolifierPool = async (pool, { taskExecutions, workerData }) => {
 
 const runPoolifierPoolBenchmark = async (
   name,
-  pool,
+  workerType,
+  poolType,
+  poolSize,
   { taskExecutions, workerData }
 ) => {
+  const pool = buildPoolifierPool(workerType, poolType, poolSize)
+  const suite = new Benchmark.Suite(name)
   return await new Promise((resolve, reject) => {
     try {
-      const suite = new Benchmark.Suite(name)
       for (const workerChoiceStrategy of Object.values(
         WorkerChoiceStrategies
       )) {
@@ -155,7 +158,12 @@ const runPoolifierPoolBenchmark = async (
         })
         .run({ async: true })
     } catch (error) {
-      reject(error)
+      pool
+        .destroy()
+        .then(() => {
+          return reject(error)
+        })
+        .catch(() => {})
     }
   })
 }
@@ -248,7 +256,6 @@ const executeTaskFunction = data => {
 
 module.exports = {
   LIST_FORMATTER,
-  buildPoolifierPool,
   executeTaskFunction,
   generateRandomInteger,
   runPoolifierPoolBenchmark