]>
Commit | Line | Data |
---|---|---|
c68d4281 | 1 | const FixedThreadPool = require('../lib/fixed') |
c2dbbe2b | 2 | let resolved = 0 |
bf962cba | 3 | const pool = new FixedThreadPool(15, |
4 | './yourWorker.js', | |
5 | { errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') }) | |
3e460d6d | 6 | |
27006a3d | 7 | const start = Date.now() |
bf962cba | 8 | const iterations = 1000 |
c2dbbe2b | 9 | for (let i = 0; i <= iterations; i++) { |
a32e02ba | 10 | pool.execute({}).then(res => { |
c2dbbe2b | 11 | resolved++ |
3e460d6d | 12 | if (resolved === iterations) { |
13 | console.log('Time take is ' + (Date.now() - start)) | |
c2dbbe2b | 14 | } |
3e460d6d | 15 | }) |
6dc67cda | 16 | } |