Commit | Line | Data |
---|---|---|
8fca9288 | 1 | import { StaticPool } from 'node-worker-threads-pool' |
35704ec7 | 2 | import { executeAsyncFn } from './utils.mjs' |
bea2d6e3 | 3 | import functionToBench from './functions/function-to-bench.js' |
479ba9f6 | 4 | |
6bd72cd0 JB |
5 | const size = parseInt(process.env.POOL_SIZE) |
6 | const iterations = parseInt(process.env.NUM_ITERATIONS) | |
be0676b3 | 7 | const data = { |
9f7e7a99 | 8 | test: 'MYBENCH', |
7a6a0a96 | 9 | taskType: process.env.TASK_TYPE, |
6bd72cd0 | 10 | taskSize: parseInt(process.env.TASK_SIZE) |
be0676b3 APA |
11 | } |
12 | ||
4bb5e44d | 13 | const staticPool = new StaticPool({ |
7a6a0a96 | 14 | size, |
be0676b3 APA |
15 | task: functionToBench |
16 | }) | |
17 | ||
18 | async function run () { | |
1655b92e | 19 | const promises = new Set() |
be0676b3 | 20 | for (let i = 0; i < iterations; i++) { |
4bb5e44d | 21 | promises.add(staticPool.exec(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 | ||
479ba9f6 | 28 | await executeAsyncFn(run) |