Fix tests run on node 10.x and add test assertion
[poolifier.git] / staticExample.js
... / ...
CommitLineData
1const FixedThreadPool = require('./lib/fixed')
2let resolved = 0
3const pool = new FixedThreadPool(15,
4 './yourWorker.js',
5 { errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') })
6
7const start = Date.now()
8const iterations = 1000
9for (let i = 0; i <= iterations; i++) {
10 pool.execute({}).then(res => {
11 resolved++
12 if (resolved === iterations) {
13 console.log('Time take is ' + (Date.now() - start))
14 }
15 })
16}