From: Jérôme Benoit Date: Sat, 6 Apr 2024 13:23:29 +0000 (+0200) Subject: perf(benchmark): port to homemade mitata fork X-Git-Tag: v3.1.30~34 X-Git-Url: https://git.piment-noir.org/?p=poolifier.git;a=commitdiff_plain;h=16534b4212013e58407946c95a53db4d8512d512 perf(benchmark): port to homemade mitata fork Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/benchmarks-utils.mjs b/benchmarks/benchmarks-utils.mjs index 5db55b3b..48101fda 100644 --- a/benchmarks/benchmarks-utils.mjs +++ b/benchmarks/benchmarks-utils.mjs @@ -1,7 +1,7 @@ import { strictEqual } from 'node:assert' import Benchmark from 'benchmark' -import { bench, group } from 'mitata' +import { bench, clear, group, run } from 'mitata' import { DynamicClusterPool, @@ -249,7 +249,7 @@ export const runPoolifierBenchmarkBenchmarkJsSuite = async ( }) } -export const buildPoolifierBenchmarkMitata = ( +export const runPoolifierBenchmarkMitata = async ( name, workerType, poolType, @@ -313,7 +313,9 @@ export const buildPoolifierBenchmarkMitata = ( } } } - return pool + await run() + await pool.destroy() + clear() } catch (error) { console.error(error) } diff --git a/benchmarks/internal/bench.mjs b/benchmarks/internal/bench.mjs index 564a4de1..480998b7 100644 --- a/benchmarks/internal/bench.mjs +++ b/benchmarks/internal/bench.mjs @@ -1,8 +1,6 @@ import { exit } from 'node:process' import { parseArgs } from 'node:util' -import { run } from 'mitata' - import { availableParallelism, PoolTypes, @@ -10,8 +8,8 @@ import { } from '../../lib/index.mjs' import { TaskFunctions } from '../benchmarks-types.cjs' import { - buildPoolifierBenchmarkMitata, - runPoolifierBenchmarkBenchmarkJsSuite + runPoolifierBenchmarkBenchmarkJsSuite, + runPoolifierBenchmarkMitata } from '../benchmarks-utils.mjs' const poolSize = availableParallelism() @@ -21,10 +19,6 @@ const workerData = { taskSize: 50000 } -let fixedThreadPool -let dynamicThreadPool -let fixedClusterPool -let dynamicClusterPool switch ( parseArgs({ args: process.argv, @@ -39,7 +33,7 @@ switch ( }).values.type ) { case 'mitata': - fixedThreadPool = buildPoolifierBenchmarkMitata( + await runPoolifierBenchmarkMitata( 'FixedThreadPool', WorkerTypes.thread, PoolTypes.fixed, @@ -49,7 +43,7 @@ switch ( workerData } ) - dynamicThreadPool = buildPoolifierBenchmarkMitata( + await runPoolifierBenchmarkMitata( 'DynamicThreadPool', WorkerTypes.thread, PoolTypes.dynamic, @@ -59,7 +53,7 @@ switch ( workerData } ) - fixedClusterPool = buildPoolifierBenchmarkMitata( + await runPoolifierBenchmarkMitata( 'FixedClusterPool', WorkerTypes.cluster, PoolTypes.fixed, @@ -69,7 +63,7 @@ switch ( workerData } ) - dynamicClusterPool = buildPoolifierBenchmarkMitata( + await runPoolifierBenchmarkMitata( 'DynamicClusterPool', WorkerTypes.cluster, PoolTypes.dynamic, @@ -79,11 +73,6 @@ switch ( workerData } ) - await run() - await fixedThreadPool.destroy() - await dynamicThreadPool.destroy() - await fixedClusterPool.destroy() - await dynamicClusterPool.destroy() break case 'benchmark.js': default: