X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fthread%2Fworker.js;h=09060ebad46032264aea8dd3f60df085cba81b8c;hb=116609a3a74b68ba940d3a0129104d4eae115ed3;hp=f5f36ed88b82cbfef176e0cbdb1d9969d9a7af1c;hpb=6e9d10db05ac2bbc85373195a5c885d2492fee61;p=poolifier.git diff --git a/benchmarks/internal/thread/worker.js b/benchmarks/internal/thread/worker.js index f5f36ed8..09060eba 100644 --- a/benchmarks/internal/thread/worker.js +++ b/benchmarks/internal/thread/worker.js @@ -1,14 +1,16 @@ 'use strict' +const { isMainThread } = require('worker_threads') const { ThreadWorker } = require('../../../lib/index') +const { executeWorkerFunction } = require('../../benchmarks-utils') +const { WorkerFunctions } = require('../../benchmarks-types') + +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 ' + isMainThread) return { ok: 1 } }