Commit | Line | Data |
---|---|---|
7f685093 JB |
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 | |
6bd72cd0 JB |
7 | const size = parseInt(process.env.POOL_SIZE) |
8 | const iterations = parseInt(process.env.NUM_ITERATIONS) | |
7f685093 JB |
9 | const data = { |
10 | test: 'MYBENCH', | |
7a6a0a96 | 11 | taskType: process.env.TASK_TYPE, |
6bd72cd0 | 12 | taskSize: parseInt(process.env.TASK_SIZE) |
7f685093 JB |
13 | } |
14 | ||
15 | async function run () { | |
79e7d368 | 16 | await start({ maxWorkers: size }) |
7f685093 JB |
17 | const promises = [] |
18 | for (let i = 0; i < iterations; i++) { | |
19 | promises.push( | |
20 | job( | |
21 | data => { | |
22 | functionToBench(data) | |
23 | }, | |
7a6a0a96 | 24 | { data, ctx: { functionToBench } } |
7f685093 JB |
25 | ) |
26 | ) | |
27 | } | |
28 | await Promise.all(promises) | |
2f8c5b5c | 29 | // eslint-disable-next-line n/no-process-exit |
7f685093 JB |
30 | process.exit() |
31 | } | |
32 | ||
33 | run() |