X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fbench.mjs;h=0e3ee055a474e5a439c5a9b1fcde3de218271193;hb=8f01ffbe12f90c234fe5acb12932b752c56905ef;hp=9eb70526dbded89565714dcf940b1a4b971cbb17;hpb=b5ca7c942f3f11b2669e1529cf46e1b1e576ef41;p=poolifier.git diff --git a/benchmarks/internal/bench.mjs b/benchmarks/internal/bench.mjs index 9eb70526..0e3ee055 100644 --- a/benchmarks/internal/bench.mjs +++ b/benchmarks/internal/bench.mjs @@ -1,4 +1,6 @@ -import { exit } from 'node:process' +import { writeFileSync } from 'node:fs' +import { env, exit } from 'node:process' +// eslint-disable-next-line n/no-unsupported-features/node-builtins import { parseArgs } from 'node:util' import { @@ -8,7 +10,7 @@ import { } from '../../lib/index.mjs' import { TaskFunctions } from '../benchmarks-types.cjs' import { - runPoolifierBenchmarkBenchmarkJsSuite, + convertTatamiNgToBmf, runPoolifierBenchmarkTatamiNg } from '../benchmarks-utils.mjs' @@ -16,8 +18,10 @@ const poolSize = availableParallelism() const taskExecutions = 1 const workerData = { function: TaskFunctions.factorial, - taskSize: 50000 + taskSize: 1000 } +const benchmarkReportFile = 'benchmark-report.json' +let benchmarkReport switch ( parseArgs({ @@ -33,89 +37,66 @@ switch ( }).values.type ) { case 'tatami-ng': - await runPoolifierBenchmarkTatamiNg( - 'FixedThreadPool', - WorkerTypes.thread, - PoolTypes.fixed, - poolSize, - { - taskExecutions, - workerData - } - ) - await runPoolifierBenchmarkTatamiNg( - 'DynamicThreadPool', - WorkerTypes.thread, - PoolTypes.dynamic, - poolSize, - { - taskExecutions, - workerData - } - ) - await runPoolifierBenchmarkTatamiNg( - 'FixedClusterPool', - WorkerTypes.cluster, - PoolTypes.fixed, - poolSize, - { - taskExecutions, - workerData - } - ) - await runPoolifierBenchmarkTatamiNg( - 'DynamicClusterPool', - WorkerTypes.cluster, - PoolTypes.dynamic, - poolSize, - { - taskExecutions, - workerData - } - ) - break - case 'benchmark.js': default: - await runPoolifierBenchmarkBenchmarkJsSuite( - 'FixedThreadPool', - WorkerTypes.thread, - PoolTypes.fixed, - poolSize, - { - taskExecutions, - workerData - } - ) - await runPoolifierBenchmarkBenchmarkJsSuite( - 'DynamicThreadPool', - WorkerTypes.thread, - PoolTypes.dynamic, - poolSize, - { - taskExecutions, - workerData - } - ) - await runPoolifierBenchmarkBenchmarkJsSuite( - 'FixedClusterPool', - WorkerTypes.cluster, - PoolTypes.fixed, - poolSize, - { - taskExecutions, - workerData - } - ) - await runPoolifierBenchmarkBenchmarkJsSuite( - 'DynamicClusterPool', - WorkerTypes.cluster, - PoolTypes.dynamic, - poolSize, - { - taskExecutions, - workerData - } + benchmarkReport = convertTatamiNgToBmf( + await runPoolifierBenchmarkTatamiNg( + 'FixedThreadPool', + WorkerTypes.thread, + PoolTypes.fixed, + poolSize, + { + taskExecutions, + workerData + } + ) ) + benchmarkReport = { + ...benchmarkReport, + ...convertTatamiNgToBmf( + await runPoolifierBenchmarkTatamiNg( + 'DynamicThreadPool', + WorkerTypes.thread, + PoolTypes.dynamic, + poolSize, + { + taskExecutions, + workerData + } + ) + ) + } + benchmarkReport = { + ...benchmarkReport, + ...convertTatamiNgToBmf( + await runPoolifierBenchmarkTatamiNg( + 'FixedClusterPool', + WorkerTypes.cluster, + PoolTypes.fixed, + poolSize, + { + taskExecutions, + workerData + } + ) + ) + } + benchmarkReport = { + ...benchmarkReport, + ...convertTatamiNgToBmf( + await runPoolifierBenchmarkTatamiNg( + 'DynamicClusterPool', + WorkerTypes.cluster, + PoolTypes.dynamic, + poolSize, + { + taskExecutions, + workerData + } + ) + ) + } + env.CI != null && + writeFileSync(benchmarkReportFile, JSON.stringify(benchmarkReport)) break }