X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Ffunctions%2Ffunction-to-bench.js;h=2f75d143330a07adb22ff9b7bcbc8a9862ca1d55;hb=6bd72cd09232827a710b41952254cab597664247;hp=b3e19fe95f81c76edec864b47812a4408b729a6c;hpb=8c97ee641800a73d02516dad3e6b5172ec477e2d;p=poolifier.git diff --git a/benchmarks/versus-external-pools/functions/function-to-bench.js b/benchmarks/versus-external-pools/functions/function-to-bench.js index b3e19fe9..2f75d143 100644 --- a/benchmarks/versus-external-pools/functions/function-to-bench.js +++ b/benchmarks/versus-external-pools/functions/function-to-bench.js @@ -1,4 +1,9 @@ const fs = require('fs') +const { + WorkerFunctions, + executeWorkerFunction + // eslint-disable-next-line n/no-unpublished-require +} = require('../../benchmarks-utils') const TaskTypes = { CPU_INTENSIVE: 'CPU_INTENSIVE', @@ -13,12 +18,8 @@ module.exports = function (data) { switch (data.taskType) { case TaskTypes.CPU_INTENSIVE: // CPU intensive task - for (let i = 0; i < data.taskSize; i++) { - const o = { - a: i - } - JSON.stringify(o) - } + data.function = data.function || WorkerFunctions.jsonIntegerSerialization + executeWorkerFunction(data) return { ok: 1 } case TaskTypes.IO_INTENSIVE: // IO intensive task