feat: add support for mitata benchmark
[poolifier.git] / benchmarks / internal / thread-worker.mjs
CommitLineData
a449b585 1import { isMainThread } from 'node:worker_threads'
ded253e2 2
8a970421 3import { ThreadWorker } from '../../lib/index.mjs'
d35e5717 4import { TaskFunctions } from '../benchmarks-types.cjs'
0804b9b4 5import { executeTaskFunction } from '../benchmarks-utils.mjs'
8a970421 6
041dc05b 7const taskFunction = data => {
8a970421 8 data = data || {}
66566c5d 9 data.function = data.function || TaskFunctions.factorial
f1c674cd 10 data.debug = data.debug || false
dbca3be9 11 const res = executeTaskFunction(data)
f1c674cd
JB
12 data.debug === true &&
13 console.debug(`This is the main thread ${isMainThread}`)
30b963d4 14 return res
8a970421
JB
15}
16
dbca3be9 17export default new ThreadWorker(taskFunction)