X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fcluster%2Fworker.js;h=29005f9c219bc9b932317d291dc8f059a2819d47;hb=767d1512978a4a45bd79189e67f703ce217342ca;hp=c7211b7bfd2b9fe5883059ef9bba8771d614381d;hpb=be0676b3936d75f22ce55b0f71a1fb03d008a01c;p=poolifier.git diff --git a/benchmarks/internal/cluster/worker.js b/benchmarks/internal/cluster/worker.js index c7211b7b..29005f9c 100644 --- a/benchmarks/internal/cluster/worker.js +++ b/benchmarks/internal/cluster/worker.js @@ -1,14 +1,15 @@ 'use strict' +const { isMaster } = require('cluster') const { ClusterWorker } = require('../../../lib/index') +const { WorkerFunctions, executeWorkerFunction } = require('../benchmark-utils') + +const debug = false function yourFunction (data) { - for (let i = 0; i <= 1000; i++) { - const o = { - a: i - } - JSON.stringify(o) - } - // console.log('This is the main thread ' + isMainThread) + data = data || {} + data.function = data.function || WorkerFunctions.jsonIntegerSerialization + executeWorkerFunction(data) + debug === true && console.debug('This is the main thread ' + isMaster) return { ok: 1 } }