refactor: cleanup object destructuration in examples
[poolifier.git] / benchmarks / versus-external-pools / fixed-piscina.mjs
CommitLineData
be0676b3 1// IMPORT LIBRARIES
8fca9288 2import Piscina from 'piscina'
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 piscina = new Piscina({
8fca9288 13 filename: './workers/piscina/function-to-bench-worker.mjs',
79e7d368 14 minThreads: size,
6bb19f6b 15 maxThreads: size,
978aad6f 16 idleTimeout: 60000 // this is the same as poolifier default
be0676b3
APA
17})
18
19async function run () {
1655b92e 20 const promises = new Set()
be0676b3 21 for (let i = 0; i < iterations; i++) {
1655b92e 22 promises.add(piscina.run(data))
be0676b3
APA
23 }
24 await Promise.all(promises)
2f8c5b5c 25 // eslint-disable-next-line n/no-process-exit
be0676b3
APA
26 process.exit()
27}
28
8fca9288 29await run()