Measurements,
PoolTypes,
WorkerChoiceStrategies,
- WorkerTypes
+ WorkerTypes,
} from '../lib/index.mjs'
import { executeTaskFunction } from './benchmarks-utils.cjs'
}
const runPoolifierPool = async (pool, { taskExecutions, workerData }) => {
- return await new Promise((resolve, reject) => {
- let executions = 0
- for (let i = 1; i <= taskExecutions; i++) {
- pool
- .execute(workerData)
- .then(() => {
- ++executions
- if (executions === taskExecutions) {
- resolve({ ok: 1 })
- }
- return undefined
- })
- .catch(err => {
- console.error(err)
- reject(err)
- })
- }
- })
+ for (let i = 1; i <= taskExecutions; i++) {
+ await pool.execute(workerData)
+ }
}
export const runPoolifierBenchmarkTatamiNg = async (
async () => {
await runPoolifierPool(pool, {
taskExecutions,
- workerData
+ workerData,
})
},
{
before: () => {
pool.setWorkerChoiceStrategy(workerChoiceStrategy, {
- measurement
+ measurement,
})
pool.enableTasksQueue(enableTasksQueue)
strictEqual(
pool.opts.workerChoiceStrategyOptions.measurement,
measurement
)
- }
+ },
}
)
})
async () => {
await runPoolifierPool(pool, {
taskExecutions,
- workerData
+ workerData,
})
},
{
workerChoiceStrategy
)
strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
- }
+ },
}
)
})
latency: {
value: stats?.avg,
lower_value: stats?.min,
- upper_value: stats?.max
+ upper_value: stats?.max,
},
throughput: {
- value: stats?.iter
- }
- }
+ value: stats?.iter,
+ },
+ },
}
})
.reduce((obj, item) => Object.assign(obj, item), {})