refactor: cleanups
[poolifier.git] / benchmarks / versus-external-pools / fixed-poolifier.mjs
CommitLineData
be0676b3 1// IMPORT LIBRARIES
8fca9288 2import { FixedThreadPool } 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 fixedPool = 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++) {
1655b92e 23 promises.add(fixedPool.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
8fca9288 30await run()