perf: reenable benchmark
[poolifier.git] / benchmarks / internal / bench.mjs
CommitLineData
00a2ffdb 1import { exit } from 'node:process'
b9ded264 2// eslint-disable-next-line n/no-unsupported-features/node-builtins
0804b9b4
JB
3import { parseArgs } from 'node:util'
4
d09b37fc 5import {
ded253e2 6 availableParallelism,
d9d8c14e 7 PoolTypes,
ded253e2 8 WorkerTypes
d09b37fc 9} from '../../lib/index.mjs'
d35e5717 10import { TaskFunctions } from '../benchmarks-types.cjs'
0804b9b4 11import {
16534b42 12 runPoolifierBenchmarkBenchmarkJsSuite,
b5ca7c94 13 runPoolifierBenchmarkTatamiNg
0804b9b4 14} from '../benchmarks-utils.mjs'
cdace0e5 15
d09b37fc 16const poolSize = availableParallelism()
cdace0e5
JB
17const taskExecutions = 1
18const workerData = {
66f0c14c 19 function: TaskFunctions.factorial,
e36fefed 20 taskSize: 1000
cdace0e5 21}
f1c674cd 22
a6bef8d2
JB
23switch (
24 parseArgs({
25 args: process.argv,
26 options: {
27 type: {
28 type: 'string',
29 short: 't'
30 }
31 },
32 strict: true,
33 allowPositionals: true
34 }).values.type
35) {
98f60ddd 36 case 'tatami-ng':
b5ca7c94 37 await runPoolifierBenchmarkTatamiNg(
0804b9b4
JB
38 'FixedThreadPool',
39 WorkerTypes.thread,
40 PoolTypes.fixed,
41 poolSize,
42 {
43 taskExecutions,
44 workerData
45 }
46 )
b5ca7c94 47 await runPoolifierBenchmarkTatamiNg(
0804b9b4
JB
48 'DynamicThreadPool',
49 WorkerTypes.thread,
50 PoolTypes.dynamic,
51 poolSize,
52 {
53 taskExecutions,
54 workerData
55 }
56 )
b5ca7c94 57 await runPoolifierBenchmarkTatamiNg(
0804b9b4
JB
58 'FixedClusterPool',
59 WorkerTypes.cluster,
60 PoolTypes.fixed,
61 poolSize,
62 {
63 taskExecutions,
64 workerData
65 }
66 )
b5ca7c94 67 await runPoolifierBenchmarkTatamiNg(
0804b9b4
JB
68 'DynamicClusterPool',
69 WorkerTypes.cluster,
70 PoolTypes.dynamic,
71 poolSize,
72 {
73 taskExecutions,
74 workerData
75 }
76 )
0804b9b4
JB
77 break
78 case 'benchmark.js':
79 default:
6da2cd97 80 await runPoolifierBenchmarkBenchmarkJsSuite(
0804b9b4
JB
81 'FixedThreadPool',
82 WorkerTypes.thread,
83 PoolTypes.fixed,
84 poolSize,
85 {
86 taskExecutions,
87 workerData
88 }
89 )
6da2cd97 90 await runPoolifierBenchmarkBenchmarkJsSuite(
0804b9b4
JB
91 'DynamicThreadPool',
92 WorkerTypes.thread,
93 PoolTypes.dynamic,
94 poolSize,
95 {
96 taskExecutions,
97 workerData
98 }
99 )
6da2cd97 100 await runPoolifierBenchmarkBenchmarkJsSuite(
0804b9b4
JB
101 'FixedClusterPool',
102 WorkerTypes.cluster,
103 PoolTypes.fixed,
104 poolSize,
105 {
106 taskExecutions,
107 workerData
108 }
109 )
6da2cd97 110 await runPoolifierBenchmarkBenchmarkJsSuite(
0804b9b4
JB
111 'DynamicClusterPool',
112 WorkerTypes.cluster,
113 PoolTypes.dynamic,
114 poolSize,
115 {
116 taskExecutions,
117 workerData
118 }
119 )
120 break
121}
00a2ffdb
JB
122
123exit()