import { exit } from 'node:process'
import { parseArgs } from 'node:util'
-import { run } from 'mitata'
-
import {
availableParallelism,
PoolTypes,
} from '../../lib/index.mjs'
import { TaskFunctions } from '../benchmarks-types.cjs'
import {
- buildPoolifierBenchmarkMitata,
- runPoolifierBenchmarkBenchmarkJs
+ runPoolifierBenchmarkBenchmarkJsSuite,
+ runPoolifierBenchmarkMitata
} from '../benchmarks-utils.mjs'
const poolSize = availableParallelism()
taskSize: 50000
}
-const options = {
- type: {
- type: 'string',
- short: 't'
- }
-}
-const { values } = parseArgs({
- args: process.argv,
- options,
- strict: true,
- allowPositionals: true
-})
-
-let fixedThreadPool
-let dynamicThreadPool
-let fixedClusterPool
-let dynamicClusterPool
-switch (values.type) {
+switch (
+ parseArgs({
+ args: process.argv,
+ options: {
+ type: {
+ type: 'string',
+ short: 't'
+ }
+ },
+ strict: true,
+ allowPositionals: true
+ }).values.type
+) {
case 'mitata':
- fixedThreadPool = buildPoolifierBenchmarkMitata(
+ await runPoolifierBenchmarkMitata(
'FixedThreadPool',
WorkerTypes.thread,
PoolTypes.fixed,
workerData
}
)
- dynamicThreadPool = buildPoolifierBenchmarkMitata(
+ await runPoolifierBenchmarkMitata(
'DynamicThreadPool',
WorkerTypes.thread,
PoolTypes.dynamic,
workerData
}
)
- fixedClusterPool = buildPoolifierBenchmarkMitata(
+ await runPoolifierBenchmarkMitata(
'FixedClusterPool',
WorkerTypes.cluster,
PoolTypes.fixed,
workerData
}
)
- dynamicClusterPool = buildPoolifierBenchmarkMitata(
+ await runPoolifierBenchmarkMitata(
'DynamicClusterPool',
WorkerTypes.cluster,
PoolTypes.dynamic,
workerData
}
)
- await run()
- await fixedThreadPool.destroy()
- await dynamicThreadPool.destroy()
- await fixedClusterPool.destroy()
- await dynamicClusterPool.destroy()
break
case 'benchmark.js':
default:
- await runPoolifierBenchmarkBenchmarkJs(
+ await runPoolifierBenchmarkBenchmarkJsSuite(
'FixedThreadPool',
WorkerTypes.thread,
PoolTypes.fixed,
workerData
}
)
- await runPoolifierBenchmarkBenchmarkJs(
+ await runPoolifierBenchmarkBenchmarkJsSuite(
'DynamicThreadPool',
WorkerTypes.thread,
PoolTypes.dynamic,
workerData
}
)
- await runPoolifierBenchmarkBenchmarkJs(
+ await runPoolifierBenchmarkBenchmarkJsSuite(
'FixedClusterPool',
WorkerTypes.cluster,
PoolTypes.fixed,
workerData
}
)
- await runPoolifierBenchmarkBenchmarkJs(
+ await runPoolifierBenchmarkBenchmarkJsSuite(
'DynamicClusterPool',
WorkerTypes.cluster,
PoolTypes.dynamic,