From 6aec0be366216d2bf76eafb51cbf1c05521e9df8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 31 Mar 2024 22:12:00 +0200 Subject: [PATCH] fix(benchmark): remove timeouting in benchmark.js MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- benchmarks/benchmarks-utils.mjs | 34 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/benchmarks/benchmarks-utils.mjs b/benchmarks/benchmarks-utils.mjs index 0cd3a172..0971e683 100644 --- a/benchmarks/benchmarks-utils.mjs +++ b/benchmarks/benchmarks-utils.mjs @@ -83,34 +83,30 @@ export const runPoolifierBenchmarkBenchmarkJs = async ( { taskExecutions, workerData } ) => { return await new Promise((resolve, reject) => { - let pool = buildPoolifierPool(workerType, poolType, poolSize) + const pool = buildPoolifierPool(workerType, poolType, poolSize) try { const suite = new Benchmark.Suite(name, { onComplete: () => { - const destroyTimeout = setTimeout(() => { - console.error('Pool destroy timeout reached (30s)') + if (pool.started && !pool.destroying) { + pool.destroy().then(resolve).catch(reject) + } else { 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(() => {}) + if (pool.started && !pool.destroying) { + pool + .destroy() + .then(() => { + return reject(event.target.error) + }) + .catch(() => {}) + } else { + reject(event.target.error) + } } }) for (const workerChoiceStrategy of Object.values( -- 2.34.1