1 import { DynamicPool } from 'node-worker-threads-pool'
2 import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs'
3 import functionToBench from './functions/function-to-bench.js'
5 const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize
7 parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations
10 taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType,
11 taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize
14 const dynamicPool = new DynamicPool(size)
16 async function run () {
17 const promises = new Set()
18 for (let i = 0; i < numIterations; i++) {
21 task: functionToBench,
23 timeout: 60000 // this is the same as poolifier default
27 await Promise.all(promises)
28 // eslint-disable-next-line n/no-process-exit
32 await executeAsyncFn(run)