build(deps-dev): bump @types/node
[poolifier.git] / benchmarks / versus-external-pools / dynamic-poolifier.mjs
CommitLineData
be0676b3 1// IMPORT LIBRARIES
8fca9288 2import { DynamicThreadPool } from 'poolifier'
be0676b3 3// FINISH IMPORT LIBRARIES
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
12const dynamicPool = new DynamicThreadPool(
02749105 13 Math.floor(size / 2),
79e7d368 14 size,
7daf2f56
JB
15 './workers/poolifier/function-to-bench-worker.mjs',
16 {
234c3142 17 enableTasksQueue: false
7daf2f56 18 }
be0676b3
APA
19)
20
21async function run () {
1655b92e 22 const promises = new Set()
be0676b3 23 for (let i = 0; i < iterations; i++) {
1655b92e 24 promises.add(dynamicPool.execute(data))
be0676b3
APA
25 }
26 await Promise.all(promises)
2f8c5b5c 27 // eslint-disable-next-line n/no-process-exit
be0676b3
APA
28 process.exit()
29}
30
8fca9288 31await run()