6 } = require('poolifier')
8 const pool
= new FixedThreadPool(availableParallelism(), './yourWorker.js', {
9 errorHandler
: e
=> console
.error(e
),
10 onlineHandler
: () => console
.info('worker is online')
14 pool
.emitter
.on(PoolEvents
.ready
, () => poolReady
++)
15 pool
.emitter
.on(PoolEvents
.busy
, () => poolBusy
++)
18 const start
= performance
.now()
19 const iterations
= 1000
20 for (let i
= 1; i
<= iterations
; i
++) {
25 if (resolved
=== iterations
) {
26 console
.info(`Time taken is ${performance.now() - start}`)
27 console
.info(`The pool was ready for ${poolReady} times`)
28 return console
.info(`The pool was busy for ${poolBusy} times`)
32 .catch(err
=> console
.error(err
))