Error handling and unit tests
[poolifier.git] / benchmarks / yourWorker.js
index 9c250220e8a510d1a9beeb589bb9300298add6ee..701aa8cf4d59cf15cd7623b0b09f8cbb0cef8928 100644 (file)
@@ -1,18 +1,20 @@
 'use strict'
 const { ThreadWorker } = require('../lib/workers')
 
+function yourFunction (data) {
+  for (let i = 0; i <= 1000; i++) {
+    const o = {
+      a: i
+    }
+    JSON.stringify(o)
+  }
+  // console.log('This is the main thread ' + isMainThread)
+  return { ok: 1 }
+}
+
 class MyWorker extends ThreadWorker {
   constructor () {
-    super((data) => {
-      for (let i = 0; i <= 1000; i++) {
-        const o = {
-          a: i
-        }
-        JSON.stringify(o)
-      }
-      // console.log('This is the main thread ' + isMainThread)
-      return { ok: 1 }
-    })
+    super(yourFunction)
   }
 }
 module.exports = new MyWorker()