X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fcluster-worker.mjs;h=1d64fde30a19d82f0e4f52cb1781a7eab9efeae6;hb=3ed0d94c139d2941fcb72dce49f7c19030325308;hp=e8d16d217313457bffccb269642644207d1292f0;hpb=e102732c0e3966b81834b2c0bdd087eb051162ad;p=poolifier.git diff --git a/benchmarks/internal/cluster-worker.mjs b/benchmarks/internal/cluster-worker.mjs index e8d16d21..1d64fde3 100644 --- a/benchmarks/internal/cluster-worker.mjs +++ b/benchmarks/internal/cluster-worker.mjs @@ -1,16 +1,15 @@ -import { isMaster } from 'cluster' +import { isPrimary } from 'node:cluster' import { ClusterWorker } from '../../lib/index.mjs' -import { executeWorkerFunction } from '../benchmarks-utils.mjs' -import { WorkerFunctions } from '../benchmarks-types.mjs' +import { executeTaskFunction } from '../benchmarks-utils.mjs' +import { TaskFunctions } from '../benchmarks-types.mjs' -const debug = false - -function workerFunction (data) { +const taskFunction = data => { data = data || {} - data.function = data.function || WorkerFunctions.jsonIntegerSerialization - executeWorkerFunction(data) - debug === true && console.debug('This is the main thread ' + isMaster) - return { ok: 1 } + data.function = data.function || TaskFunctions.jsonIntegerSerialization + data.debug = data.debug || false + const res = executeTaskFunction(data) + data.debug === true && console.debug(`This is the main thread ${isPrimary}`) + return res } -export default new ClusterWorker(workerFunction) +export default new ClusterWorker(taskFunction)