1 import { ThreadPool } from 'nanothreads'
2 import { executeAsyncFn } from './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 threadPool = new ThreadPool({
14 task: functionToBench,
18 async function run () {
19 const promises = new Set()
20 for (let i = 0; i < iterations; i++) {
21 promises.add(threadPool.exec(data))
23 await Promise.all(promises)
24 // eslint-disable-next-line n/no-process-exit
28 await executeAsyncFn(run)