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