import { strictEqual } from 'node:assert'
import Benchmark from 'benchmark'
-import { bench, group } from 'mitata'
+import { bench, clear, group, run } from 'mitata'
import {
DynamicClusterPool,
})
}
-export const buildPoolifierBenchmarkMitata = (
+export const runPoolifierBenchmarkMitata = async (
name,
workerType,
poolType,
}
}
}
- return pool
+ await run()
+ await pool.destroy()
+ clear()
} catch (error) {
console.error(error)
}
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,
- runPoolifierBenchmarkBenchmarkJsSuite
+ runPoolifierBenchmarkBenchmarkJsSuite,
+ runPoolifierBenchmarkMitata
} from '../benchmarks-utils.mjs'
const poolSize = availableParallelism()
taskSize: 50000
}
-let fixedThreadPool
-let dynamicThreadPool
-let fixedClusterPool
-let dynamicClusterPool
switch (
parseArgs({
args: process.argv,
}).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: