refactor: benchmark specific section
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 31 Mar 2024 00:08:43 +0000 (01:08 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 31 Mar 2024 00:08:43 +0000 (01:08 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
benchmarks/benchmarks-utils.mjs

index 03596b276c3cae5abd1b9fc074e11f7442ddf6ca..f04e4d0f64a0608b9258d5b346a5f4ce9fd21501 100644 (file)
@@ -100,23 +100,27 @@ export const runPoolifierBenchmarkBenchmarkJs = async (
                   enableTasksQueue ? 'with' : 'without'
                 } tasks queue`,
                 async () => {
-                  pool.setWorkerChoiceStrategy(workerChoiceStrategy, {
-                    measurement
-                  })
-                  pool.enableTasksQueue(enableTasksQueue)
-                  strictEqual(
-                    pool.opts.workerChoiceStrategy,
-                    workerChoiceStrategy
-                  )
-                  strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
-                  strictEqual(
-                    pool.opts.workerChoiceStrategyOptions.measurement,
-                    measurement
-                  )
                   await runPoolifierPool(pool, {
                     taskExecutions,
                     workerData
                   })
+                },
+                {
+                  onStart: () => {
+                    pool.setWorkerChoiceStrategy(workerChoiceStrategy, {
+                      measurement
+                    })
+                    pool.enableTasksQueue(enableTasksQueue)
+                    strictEqual(
+                      pool.opts.workerChoiceStrategy,
+                      workerChoiceStrategy
+                    )
+                    strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
+                    strictEqual(
+                      pool.opts.workerChoiceStrategyOptions.measurement,
+                      measurement
+                    )
+                  }
                 }
               )
             }
@@ -126,17 +130,21 @@ export const runPoolifierBenchmarkBenchmarkJs = async (
                 enableTasksQueue ? 'with' : 'without'
               } tasks queue`,
               async () => {
-                pool.setWorkerChoiceStrategy(workerChoiceStrategy)
-                pool.enableTasksQueue(enableTasksQueue)
-                strictEqual(
-                  pool.opts.workerChoiceStrategy,
-                  workerChoiceStrategy
-                )
-                strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
                 await runPoolifierPool(pool, {
                   taskExecutions,
                   workerData
                 })
+              },
+              {
+                onStart: () => {
+                  pool.setWorkerChoiceStrategy(workerChoiceStrategy)
+                  pool.enableTasksQueue(enableTasksQueue)
+                  strictEqual(
+                    pool.opts.workerChoiceStrategy,
+                    workerChoiceStrategy
+                  )
+                  strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
+                }
               }
             )
           }