X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=benchmarks%2Fbenchmarks-utils.mjs;h=6c01efcb348fa7ae11faf07131a3ea4d307cde0a;hb=5993cfc5a031fd2d64f644505db125bc1d28b05b;hp=8620dd681b10be4b6019dfc3d2be0dcfcf770311;hpb=8f01ffbe12f90c234fe5acb12932b752c56905ef;p=poolifier.git diff --git a/benchmarks/benchmarks-utils.mjs b/benchmarks/benchmarks-utils.mjs index 8620dd68..6c01efcb 100644 --- a/benchmarks/benchmarks-utils.mjs +++ b/benchmarks/benchmarks-utils.mjs @@ -10,7 +10,7 @@ import { Measurements, PoolTypes, WorkerChoiceStrategies, - WorkerTypes + WorkerTypes, } from '../lib/index.mjs' import { executeTaskFunction } from './benchmarks-utils.cjs' @@ -54,24 +54,9 @@ const buildPoolifierPool = (workerType, poolType, poolSize, poolOptions) => { } 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 ( @@ -95,13 +80,13 @@ export const runPoolifierBenchmarkTatamiNg = async ( async () => { await runPoolifierPool(pool, { taskExecutions, - workerData + workerData, }) }, { before: () => { pool.setWorkerChoiceStrategy(workerChoiceStrategy, { - measurement + measurement, }) pool.enableTasksQueue(enableTasksQueue) strictEqual( @@ -113,7 +98,7 @@ export const runPoolifierBenchmarkTatamiNg = async ( pool.opts.workerChoiceStrategyOptions.measurement, measurement ) - } + }, } ) }) @@ -127,7 +112,7 @@ export const runPoolifierBenchmarkTatamiNg = async ( async () => { await runPoolifierPool(pool, { taskExecutions, - workerData + workerData, }) }, { @@ -139,7 +124,7 @@ export const runPoolifierBenchmarkTatamiNg = async ( workerChoiceStrategy ) strictEqual(pool.opts.enableTasksQueue, enableTasksQueue) - } + }, } ) }) @@ -163,12 +148,12 @@ export const convertTatamiNgToBmf = report => { 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), {})