From: Jérôme Benoit Date: Sun, 23 Jul 2023 19:01:23 +0000 (+0200) Subject: perf: add measurement coverage to benchmark X-Git-Tag: v2.6.21~29 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d9d8c14e8c3bf643e42c84b4cc5144da899dc744;hp=23a6c28d3cc6edb778653a4d9d9a4d36f9a961c3;p=poolifier.git perf: add measurement coverage to benchmark Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/benchmarks-types.mjs b/benchmarks/benchmarks-types.mjs index dcffd136..3287cc3c 100644 --- a/benchmarks/benchmarks-types.mjs +++ b/benchmarks/benchmarks-types.mjs @@ -1,10 +1,6 @@ -import { PoolTypes, WorkerTypes } from '../lib/index.mjs' - -const WorkerFunctions = { +export const WorkerFunctions = { jsonIntegerSerialization: 'jsonIntegerSerialization', fibonacci: 'fibonacci', factorial: 'factorial', readWriteFiles: 'readWriteFiles' } - -export { PoolTypes, WorkerFunctions, WorkerTypes } diff --git a/benchmarks/benchmarks-utils.mjs b/benchmarks/benchmarks-utils.mjs index 8819c592..48c8fc3e 100644 --- a/benchmarks/benchmarks-utils.mjs +++ b/benchmarks/benchmarks-utils.mjs @@ -4,9 +4,11 @@ import { DynamicClusterPool, DynamicThreadPool, FixedClusterPool, - FixedThreadPool + FixedThreadPool, + PoolTypes, + WorkerTypes } from '../lib/index.mjs' -import { PoolTypes, WorkerFunctions, WorkerTypes } from './benchmarks-types.mjs' +import { WorkerFunctions } from './benchmarks-types.mjs' export const runTest = async (pool, { taskExecutions, workerData }) => { return new Promise((resolve, reject) => { diff --git a/benchmarks/internal/bench.mjs b/benchmarks/internal/bench.mjs index 41c035e6..48f30f66 100644 --- a/benchmarks/internal/bench.mjs +++ b/benchmarks/internal/bench.mjs @@ -1,13 +1,12 @@ import { add, complete, cycle, save, suite } from 'benny' import { + Measurements, + PoolTypes, WorkerChoiceStrategies, + WorkerTypes, availableParallelism } from '../../lib/index.mjs' -import { - PoolTypes, - WorkerFunctions, - WorkerTypes -} from '../benchmarks-types.mjs' +import { WorkerFunctions } from '../benchmarks-types.mjs' import { buildPool, runTest } from '../benchmarks-utils.mjs' const poolSize = availableParallelism() @@ -18,26 +17,31 @@ for (const poolType of Object.values(PoolTypes)) { continue } for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) { - for (const tasksQueue of [false, true]) { - const pool = buildPool( - workerType, - poolType, - poolSize, - tasksQueue - ? { - ...{ - workerChoiceStrategy - }, - ...{ enableTasksQueue: true } - } - : { - workerChoiceStrategy - } - ) - pools.push([ - `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${tasksQueue}`, - pool - ]) + for (const enableTasksQueue of [false, true]) { + if (workerChoiceStrategy === WorkerChoiceStrategies.FAIR_SHARE) { + for (const measurement of [Measurements.runTime, Measurements.elu]) { + const pool = buildPool(workerType, poolType, poolSize, { + workerChoiceStrategy, + workerChoiceStrategyOptions: { + measurement + }, + enableTasksQueue + }) + pools.push([ + `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}|measurement:${measurement}`, + pool + ]) + } + } else { + const pool = buildPool(workerType, poolType, poolSize, { + workerChoiceStrategy, + enableTasksQueue + }) + pools.push([ + `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}`, + pool + ]) + } } } }