6dc67cda |
1 | const FixedThreadPool = require('./fixed') |
c2dbbe2b |
2 | let resolved = 0 |
27006a3d |
3 | const pool = new FixedThreadPool(3, './yourWorker.js') |
6dc67cda |
4 | |
27006a3d |
5 | async function proof () { |
6 | const o = { |
7 | a: 123 |
8 | } |
9 | const res = await pool.execute(o) |
10 | // console.log('Here we are') |
11 | console.log('I am logging the result ' + res) |
12 | } |
3e460d6d |
13 | |
27006a3d |
14 | // proof() |
3e460d6d |
15 | |
27006a3d |
16 | const start = Date.now() |
17 | const iterations = 50000 |
c2dbbe2b |
18 | for (let i = 0; i <= iterations; i++) { |
19 | const o = { |
20 | a: i |
21 | } |
27006a3d |
22 | pool.execute(o).then(res => { |
c2dbbe2b |
23 | console.log(res) |
24 | resolved++ |
3e460d6d |
25 | if (resolved === iterations) { |
26 | console.log('Time take is ' + (Date.now() - start)) |
c2dbbe2b |
27 | } |
3e460d6d |
28 | }) |
6dc67cda |
29 | } |