fix: fix formatting issue.
[poolifier.git] / benchmarks / versus-external-pools / fixed-worker-nodes.js
CommitLineData
589f0f1c 1'use strict'
6c063733 2// IMPORT LIBRARIES
bea2d6e3 3const WorkerNodes = require('worker-nodes')
6c063733 4// FINISH IMPORT LIBRARIES
6bd72cd0
JB
5const size = parseInt(process.env.POOL_SIZE)
6const iterations = parseInt(process.env.NUM_ITERATIONS)
6c063733
JB
7const data = {
8 test: 'MYBENCH',
7a6a0a96 9 taskType: process.env.TASK_TYPE,
6bd72cd0 10 taskSize: parseInt(process.env.TASK_SIZE)
6c063733
JB
11}
12
13const workerNodes = new WorkerNodes(
bea2d6e3 14 require.resolve('./workers/worker-nodes/function-to-bench-worker'),
6c063733
JB
15 {
16 minWorkers: size,
17 maxWorkers: size,
18 taskTimeout: 60000 // this is the same as poolifier default
19 }
20)
21
22async function run () {
1655b92e 23 const promises = new Set()
6c063733 24 for (let i = 0; i < iterations; i++) {
1655b92e 25 promises.add(workerNodes.call.functionToBench(data))
6c063733
JB
26 }
27 await Promise.all(promises)
2f8c5b5c 28 // eslint-disable-next-line n/no-process-exit
6c063733
JB
29 process.exit()
30}
041dc05b 31(async () => {
bea2d6e3
JB
32 try {
33 await run()
34 } catch (e) {
35 console.error(e)
36 // eslint-disable-next-line n/no-process-exit
37 process.exit(1)
38 }
39})()