Enchance benchmarking code
[poolifier.git] / benchmarks / internal / cluster / worker.js
CommitLineData
57df5469 1'use strict'
23ff945a 2const { isMaster } = require('cluster')
be0676b3 3const { ClusterWorker } = require('../../../lib/index')
2d2e32c2 4const { WorkerFunctions, executeWorkerFunction } = require('../benchmark-utils')
57df5469 5
23ff945a
JB
6const debug = false
7
106744f7 8function yourFunction (data) {
2d2e32c2
JB
9 data = data || {}
10 data.function = data.function || WorkerFunctions.jsonIntegerSerialization
11 executeWorkerFunction(data)
23ff945a 12 debug === true && console.debug('This is the main thread ' + isMaster)
106744f7 13 return { ok: 1 }
14}
15
325f50bc 16module.exports = new ClusterWorker(yourFunction)