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