| 1 | const FixedThreadPool = require('./fixed') |
| 2 | let resolved = 0 |
| 3 | const pool = new FixedThreadPool(3, './yourWorker.js') |
| 4 | |
| 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 | } |
| 13 | |
| 14 | // proof() |
| 15 | |
| 16 | const start = Date.now() |
| 17 | const iterations = 50000 |
| 18 | for (let i = 0; i <= iterations; i++) { |
| 19 | const o = { |
| 20 | a: i |
| 21 | } |
| 22 | pool.execute(o).then(res => { |
| 23 | console.log(res) |
| 24 | resolved++ |
| 25 | if (resolved === iterations) { |
| 26 | console.log('Time take is ' + (Date.now() - start)) |
| 27 | } |
| 28 | }) |
| 29 | } |