Apply dependencies update
[poolifier.git] / benchmarks / versus-external-pools / fixed-piscina.js
CommitLineData
be0676b3
APA
1// IMPORT LIBRARIES
2const Piscina = require('piscina')
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({
9f7e7a99 13 filename: './workers/piscina/function-to-bench-worker.js',
79e7d368 14 minThreads: size,
978aad6f 15 idleTimeout: 60000 // this is the same as poolifier default
be0676b3
APA
16})
17
18async function run () {
19 const promises = []
20 for (let i = 0; i < iterations; i++) {
73cda448 21 promises.push(piscina.run(data))
be0676b3
APA
22 }
23 await Promise.all(promises)
2f8c5b5c 24 // eslint-disable-next-line n/no-process-exit
be0676b3
APA
25 process.exit()
26}
27
28run()