Working implementation with a very good benchmark based on num of threads
[poolifier.git] / proof.js
index daf55240418fffabb96901d5c2eab79403ca830a..afa3a28ddb2bccd391ba562a64e0284eae157c4f 100644 (file)
--- a/proof.js
+++ b/proof.js
@@ -1,18 +1,29 @@
 const FixedThreadPool = require('./fixed')
 let resolved = 0
+const pool = new FixedThreadPool(3, './yourWorker.js')
 
-const pool = new FixedThreadPool(100)
-let start = Date.now()
-const iterations = 5000
+async function proof () {
+  const o = {
+    a: 123
+  }
+  const res = await pool.execute(o)
+  // console.log('Here we are')
+  console.log('I am logging the result ' + res)
+}
+
+// proof()
+
+const start = Date.now()
+const iterations = 50000
 for (let i = 0; i <= iterations; i++) {
   const o = {
     a: i
   }
-  pool.execute(JSON.stringify, o).then(res => {
+  pool.execute(o).then(res => {
     console.log(res)
     resolved++
-    if(resolved === iterations) {
-         console.log('Time take is ' + (Date.now() - start))
+    if (resolved === iterations) {
+      console.log('Time take is ' + (Date.now() - start))
     }
-  } )
+  })
 }