Add benchmark script (#104)
[poolifier.git] / examples / staticExample.js
index f125c477e20df4179c78984eb05f56fbb1a342ed..d81e3484e89946374cc3056208e4d888a0162722 100644 (file)
@@ -8,10 +8,14 @@ const pool = new FixedThreadPool(15, './yourWorker.js', {
 const start = Date.now()
 const iterations = 1000
 for (let i = 0; i <= iterations; i++) {
-  pool.execute({}).then(res => {
-    resolved++
-    if (resolved === iterations) {
-      console.log('Time take is ' + (Date.now() - start))
-    }
-  })
+  pool
+    .execute({})
+    .then(res => {
+      resolved++
+      if (resolved === iterations) {
+        return console.log('Time take is ' + (Date.now() - start))
+      }
+      return null
+    })
+    .catch(err => console.error(err))
 }