1 import { DynamicThreadPool } from 'poolifier'
2 import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs'
4 const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize
6 parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations
9 taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType,
10 taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize
13 const dynamicThreadPool = new DynamicThreadPool(
16 './workers/poolifier/function-to-bench-worker.mjs',
18 enableTasksQueue: false
22 async function run () {
23 const promises = new Set()
24 for (let i = 0; i < numIterations; i++) {
25 promises.add(dynamicThreadPool.execute(data))
27 await Promise.all(promises)
28 // eslint-disable-next-line n/no-process-exit
32 await executeAsyncFn(run)