1 import { DynamicPool } from 'node-worker-threads-pool'
2 import { executeAsyncFn } from '../benchmarks-utils.mjs'
3 import functionToBench from './functions/function-to-bench.js'
5 const size = parseInt(process.env.POOL_SIZE)
6 const iterations = parseInt(process.env.NUM_ITERATIONS)
9 taskType: process.env.TASK_TYPE,
10 taskSize: parseInt(process.env.TASK_SIZE)
13 const dynamicPool = new DynamicPool(size)
15 async function run () {
16 const promises = new Set()
17 for (let i = 0; i < iterations; i++) {
20 task: functionToBench,
22 timeout: 60000 // this is the same as poolifier default
26 await Promise.all(promises)
27 // eslint-disable-next-line n/no-process-exit
31 await executeAsyncFn(run)