5 } = require('poolifier')
7 const pool
= new FixedThreadPool(availableParallelism(), './yourWorker.js', {
8 errorHandler
: e
=> console
.error(e
),
9 onlineHandler
: () => console
.info('worker is online')
12 pool
.emitter
.on(PoolEvents
.busy
, () => poolBusy
++)
15 const start
= performance
.now()
16 const iterations
= 1000
17 for (let i
= 1; i
<= iterations
; i
++) {
22 if (resolved
=== iterations
) {
23 console
.info('Time taken is ' + (performance
.now() - start
))
24 return console
.info('The pool was busy for ' + poolBusy
+ ' times')
28 .catch(err
=> console
.error(err
))