-const poolifierSuite = new Benchmark.Suite('Poolifier')
-
-for (const pool of [fixedThreadPool]) {
- for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
- for (const enableTasksQueue of [false, true]) {
- poolifierSuite.add(
- `${getPoolImplementationName(pool)}|${workerChoiceStrategy}|${
- enableTasksQueue ? 'with' : 'without'
- } tasks queue`,
- async () => {
- pool.setWorkerChoiceStrategy(workerChoiceStrategy)
- pool.enableTasksQueue(enableTasksQueue)
- assert.strictEqual(
- pool.opts.workerChoiceStrategy,
- workerChoiceStrategy
- )
- assert.strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
- await runPoolifierTest(pool, {
- taskExecutions,
- workerData
- })
- }
- )
- }
- }
+let fixedThreadPool
+let dynamicThreadPool
+let fixedClusterPool
+let dynamicClusterPool
+switch (
+ parseArgs({
+ args: process.argv,
+ options: {
+ type: {
+ type: 'string',
+ short: 't'
+ }
+ },
+ strict: true,
+ allowPositionals: true
+ }).values.type
+) {
+ case 'mitata':
+ fixedThreadPool = buildPoolifierBenchmarkMitata(
+ 'FixedThreadPool',
+ WorkerTypes.thread,
+ PoolTypes.fixed,
+ poolSize,
+ {
+ taskExecutions,
+ workerData
+ }
+ )
+ dynamicThreadPool = buildPoolifierBenchmarkMitata(
+ 'DynamicThreadPool',
+ WorkerTypes.thread,
+ PoolTypes.dynamic,
+ poolSize,
+ {
+ taskExecutions,
+ workerData
+ }
+ )
+ fixedClusterPool = buildPoolifierBenchmarkMitata(
+ 'FixedClusterPool',
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
+ poolSize,
+ {
+ taskExecutions,
+ workerData
+ }
+ )
+ dynamicClusterPool = buildPoolifierBenchmarkMitata(
+ 'DynamicClusterPool',
+ WorkerTypes.cluster,
+ PoolTypes.dynamic,
+ poolSize,
+ {
+ taskExecutions,
+ workerData
+ }
+ )
+ await run()
+ await fixedThreadPool.destroy()
+ await dynamicThreadPool.destroy()
+ await fixedClusterPool.destroy()
+ await dynamicClusterPool.destroy()
+ 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
+ }
+ )
+ break