refactor: default benchmark to factorial
[poolifier.git] / benchmarks / internal / cluster-worker.cjs
1 const { isPrimary } = require('node:cluster')
2 const { ClusterWorker } = require('../../lib/index.cjs')
3 const { executeTaskFunction } = require('../benchmarks-utils.cjs')
4 const { TaskFunctions } = require('../benchmarks-types.cjs')
5
6 const taskFunction = data => {
7 data = data || {}
8 data.function = data.function || TaskFunctions.factorial
9 data.debug = data.debug || false
10 const res = executeTaskFunction(data)
11 data.debug === true && console.debug(`This is the main thread ${isPrimary}`)
12 return res
13 }
14
15 module.exports = new ClusterWorker(taskFunction)