Linting
[poolifier.git] / staticExample.js
CommitLineData
a32e02ba 1const FixedThreadPool = require('./lib/fixed')
c2dbbe2b 2let resolved = 0
bf962cba 3const pool = new FixedThreadPool(15,
4 './yourWorker.js',
5 { errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') })
3e460d6d 6
27006a3d 7const start = Date.now()
bf962cba 8const iterations = 1000
c2dbbe2b 9for (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}