X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fcluster-worker.js;h=18bd648c72ce73d454b3503b038719aeade6bd11;hb=58c0dd01a282b063f30a1d4b71b98d1426239c04;hp=a4742a28d43fafe7fe1e21e2e0b6cfe3932805c8;hpb=cdace0e5b9082804893de9501372490ee1064090;p=poolifier.git diff --git a/benchmarks/internal/cluster-worker.js b/benchmarks/internal/cluster-worker.js index a4742a28..18bd648c 100644 --- a/benchmarks/internal/cluster-worker.js +++ b/benchmarks/internal/cluster-worker.js @@ -1,17 +1,15 @@ -'use strict' -const { isMaster } = require('cluster') +const { isPrimary } = require('node:cluster') const { ClusterWorker } = require('../../lib') -const { executeWorkerFunction } = require('../benchmarks-utils') -const { WorkerFunctions } = require('../benchmarks-types') +const { executeTaskFunction } = require('../benchmarks-utils.js') +const { TaskFunctions } = require('../benchmarks-types.js') -const debug = false - -function yourFunction (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 } -module.exports = new ClusterWorker(yourFunction) +module.exports = new ClusterWorker(taskFunction)