Commit | Line | Data |
---|---|---|
be0676b3 APA |
1 | // IMPORT LIBRARIES |
2 | const { FixedThreadPool, DynamicThreadPool } = require('poolifier') | |
3 | // FINISH IMPORT LIBRARIES | |
4 | const size = process.env.POOL_SIZE | |
5 | const iterations = process.env.NUM_ITERATIONS | |
6 | const data = { | |
7 | test: 'MYBENCH' | |
8 | } | |
9 | ||
10 | const fixedPool = new FixedThreadPool( | |
11 | size, | |
12 | './workers/poolifier/json-stringify.worker.js', | |
13 | { | |
14 | maxTasks: 100000 | |
15 | } | |
16 | ) | |
17 | ||
18 | async function run () { | |
19 | const promises = [] | |
20 | for (let i = 0; i < iterations; i++) { | |
21 | promises.push(fixedPool.execute(data)) | |
22 | } | |
23 | await Promise.all(promises) | |
24 | process.exit() | |
25 | } | |
26 | ||
27 | run() |