Working implementation with a very good benchmark based on num of threads
[poolifier.git] / proof.js
CommitLineData
6dc67cda 1const FixedThreadPool = require('./fixed')
c2dbbe2b 2let resolved = 0
27006a3d 3const pool = new FixedThreadPool(3, './yourWorker.js')
6dc67cda 4
27006a3d 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}
3e460d6d 13
27006a3d 14// proof()
3e460d6d 15
27006a3d 16const start = Date.now()
17const iterations = 50000
c2dbbe2b 18for (let i = 0; i <= iterations; i++) {
19 const o = {
20 a: i
21 }
27006a3d 22 pool.execute(o).then(res => {
c2dbbe2b 23 console.log(res)
24 resolved++
3e460d6d 25 if (resolved === iterations) {
26 console.log('Time take is ' + (Date.now() - start))
c2dbbe2b 27 }
3e460d6d 28 })
6dc67cda 29}