{ taskExecutions, workerData }
) => {
return await new Promise((resolve, reject) => {
- const pool = buildPoolifierPool(workerType, poolType, poolSize)
+ let pool = buildPoolifierPool(workerType, poolType, poolSize)
try {
- const suite = new Benchmark.Suite(name)
+ const suite = new Benchmark.Suite(name, {
+ onComplete: () => {
+ const destroyTimeout = setTimeout(() => {
+ console.error('Pool destroy timeout reached (30s)')
+ resolve()
+ pool = undefined
+ }, 30000)
+ pool
+ .destroy()
+ .then(resolve)
+ .catch(reject)
+ .finally(() => {
+ clearTimeout(destroyTimeout)
+ })
+ .catch(() => {})
+ },
+ onCycle: event => {
+ console.info(event.target.toString())
+ },
+ onError: event => {
+ pool
+ .destroy()
+ .then(() => {
+ return reject(event.target.error)
+ })
+ .catch(() => {})
+ }
+ })
for (const workerChoiceStrategy of Object.values(
WorkerChoiceStrategies
)) {
Measurements.elu
]) {
suite.add(
- `${name} with ${workerChoiceStrategy}, with ${measurement} and ${
+ `${name} with ${workerChoiceStrategy}, with measurement ${measurement} and ${
enableTasksQueue ? 'with' : 'without'
} tasks queue`,
async () => {
}
}
suite
- .on('cycle', event => {
- console.info(event.target.toString())
- })
.on('complete', function () {
console.info(
'Fastest is ' +
LIST_FORMATTER.format(this.filter('fastest').map('name'))
)
- const destroyTimeout = setTimeout(() => {
- console.error('Pool destroy timeout reached (30s)')
- resolve()
- }, 30000)
- pool
- .destroy()
- .then(resolve)
- .catch(reject)
- .finally(() => {
- clearTimeout(destroyTimeout)
- })
- .catch(() => {})
})
- .run({ async: true })
+ .run({ async: true, queued: true })
} catch (error) {
pool
.destroy()