Working implementation with a very good benchmark based on num of threads
[poolifier.git] / proof.js
index 9f127e08db14933b15a6d01fe53513581464dc6d..afa3a28ddb2bccd391ba562a64e0284eae157c4f 100644 (file)
--- a/proof.js
+++ b/proof.js
@@ -1,7 +1,29 @@
 const FixedThreadPool = require('./fixed')
+let resolved = 0
+const pool = new FixedThreadPool(3, './yourWorker.js')
 
-const o = {
-  a: 'asdfsadfafdgmnsdfmnbgsdfgbsdfmnbgsdfmnbgsmd,fbgsmndfbg'
+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(o).then(res => {
+    console.log(res)
+    resolved++
+    if (resolved === iterations) {
+      console.log('Time take is ' + (Date.now() - start))
+    }
+  })
 }
-const pool = new FixedThreadPool(3)
-pool.execute(JSON.stringify, o).then(res => console.log(res))