perf: add benchmark defaults to external pools benchmark
[poolifier.git] / benchmarks / versus-external-pools / dynamic-node-worker-threads-pool.mjs
index c4be1ee1c6d1a0ca312d1597c1d8e4a48406d5fd..7b7361d09f18b9113984557fcdc042c01d515552 100644 (file)
@@ -1,20 +1,21 @@
 import { DynamicPool } from 'node-worker-threads-pool'
-import { executeAsyncFn } from './utils.mjs'
+import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs'
 import functionToBench from './functions/function-to-bench.js'
 
-const size = parseInt(process.env.POOL_SIZE)
-const iterations = parseInt(process.env.NUM_ITERATIONS)
+const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize
+const numIterations =
+  parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations
 const data = {
   test: 'MYBENCH',
-  taskType: process.env.TASK_TYPE,
-  taskSize: parseInt(process.env.TASK_SIZE)
+  taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType,
+  taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize
 }
 
 const dynamicPool = new DynamicPool(size)
 
 async function run () {
   const promises = new Set()
-  for (let i = 0; i < iterations; i++) {
+  for (let i = 0; i < numIterations; i++) {
     promises.add(
       dynamicPool.exec({
         task: functionToBench,