Merge pull request #1261 from poolifier/dependabot/npm_and_yarn/examples/typescript...
[poolifier.git] / benchmarks / versus-external-pools / fixed-poolifier.mjs
CommitLineData
8fca9288 1import { FixedThreadPool } from 'poolifier'
35704ec7 2import { executeAsyncFn } from './utils.mjs'
479ba9f6 3
6bd72cd0
JB
4const size = parseInt(process.env.POOL_SIZE)
5const iterations = parseInt(process.env.NUM_ITERATIONS)
be0676b3 6const data = {
9f7e7a99 7 test: 'MYBENCH',
7a6a0a96 8 taskType: process.env.TASK_TYPE,
6bd72cd0 9 taskSize: parseInt(process.env.TASK_SIZE)
be0676b3
APA
10}
11
4bb5e44d 12const fixedThreadPool = new FixedThreadPool(
79e7d368 13 size,
7daf2f56
JB
14 './workers/poolifier/function-to-bench-worker.mjs',
15 {
234c3142 16 enableTasksQueue: false
7daf2f56 17 }
be0676b3
APA
18)
19
20async function run () {
1655b92e 21 const promises = new Set()
be0676b3 22 for (let i = 0; i < iterations; i++) {
4bb5e44d 23 promises.add(fixedThreadPool.execute(data))
be0676b3
APA
24 }
25 await Promise.all(promises)
2f8c5b5c 26 // eslint-disable-next-line n/no-process-exit
be0676b3
APA
27 process.exit()
28}
29
479ba9f6 30await executeAsyncFn(run)