Switch eslint-plugin-node to supported eslint-plugin-n
[poolifier.git] / benchmarks / versus-external-pools / fixed-microjob.js
1 // IMPORT LIBRARIES
2 const { job, start } = require('microjob')
3 // FINISH IMPORT LIBRARIES
4 // IMPORT FUNCTION TO BENCH
5 const functionToBench = require('./functions/function-to-bench')
6 // FINISH IMPORT FUNCTION TO BENCH
7 const size = Number(process.env.POOL_SIZE)
8 const iterations = Number(process.env.NUM_ITERATIONS)
9 const data = {
10 test: 'MYBENCH',
11 taskType: process.env.TASK_TYPE,
12 taskSize: process.env.TASK_SIZE
13 }
14
15 async function run () {
16 await start({ maxWorkers: size })
17 const promises = []
18 for (let i = 0; i < iterations; i++) {
19 promises.push(
20 job(
21 data => {
22 functionToBench(data)
23 },
24 { data, ctx: { functionToBench } }
25 )
26 )
27 }
28 await Promise.all(promises)
29 // eslint-disable-next-line n/no-process-exit
30 process.exit()
31 }
32
33 run()