refactor: cleanup internal benchmark code
[poolifier.git] / tests / worker-files / thread / testWorker.js
index 3556da01f8051960125d833ec4b38e7196f6ad94..2b86fde282c6ed28106656164d7af1275b479b00 100644 (file)
@@ -1,15 +1,17 @@
 'use strict'
-const { ThreadWorker } = require('../../../lib/index')
+const { ThreadWorker, KillBehaviors } = require('../../../lib')
 const { isMainThread } = require('worker_threads')
+const TestUtils = require('../../test-utils')
+const { WorkerFunctions } = require('../../test-types')
 
 function test (data) {
-  for (let i = 0; i <= 50; i++) {
-    const o = {
-      a: i
-    }
-    JSON.stringify(o)
-  }
+  data = data || {}
+  data.function = data.function || WorkerFunctions.jsonIntegerSerialization
+  TestUtils.executeWorkerFunction(data)
   return isMainThread
 }
 
-module.exports = new ThreadWorker(test, { maxInactiveTime: 500 })
+module.exports = new ThreadWorker(test, {
+  maxInactiveTime: 500,
+  killBehavior: KillBehaviors.HARD
+})