Working implementation with a very good benchmark based on num of threads
[poolifier.git] / proof.js
... / ...
CommitLineData
1const FixedThreadPool = require('./fixed')
2let resolved = 0
3const pool = new FixedThreadPool(3, './yourWorker.js')
4
5async function proof () {
6 const o = {
7 a: 123
8 }
9 const res = await pool.execute(o)
10 // console.log('Here we are')
11 console.log('I am logging the result ' + res)
12}
13
14// proof()
15
16const start = Date.now()
17const iterations = 50000
18for (let i = 0; i <= iterations; i++) {
19 const o = {
20 a: i
21 }
22 pool.execute(o).then(res => {
23 console.log(res)
24 resolved++
25 if (resolved === iterations) {
26 console.log('Time take is ' + (Date.now() - start))
27 }
28 })
29}