Add benchmark script (#104)
[poolifier.git] / examples / dynamicExample.js
index 22b4f19c4b7394c92b1b91b7d8ffad432e810e4c..4003c53462878652804fb8a051feeb792553c051 100644 (file)
@@ -10,11 +10,15 @@ pool.emitter.on('FullPool', () => maxReached++)
 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))
-      console.log('The pool was full for ' + maxReached + ' times')
-    }
-  })
+  pool
+    .execute({})
+    .then(res => {
+      resolved++
+      if (resolved === iterations) {
+        console.log('Time take is ' + (Date.now() - start))
+        return console.log('The pool was full for ' + maxReached + ' times')
+      }
+      return null
+    })
+    .catch(err => console.error(err))
 }