From c16cf340699cf198ca10146f30c158697afff908 Mon Sep 17 00:00:00 2001 From: naugtur Date: Fri, 15 Nov 2024 13:51:24 +0100 Subject: [PATCH] feat: add enough context to plugin methods to figure out bench task name --- lib/clock.js | 2 +- lib/lifecycle.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/clock.js b/lib/clock.js index 933d999..54d65af 100644 --- a/lib/clock.js +++ b/lib/clock.js @@ -224,7 +224,7 @@ async function clockBenchmark(bench, recommendedCount) { result[0] = Math.max(MIN_RESOLUTION, result[0]); for (const p of bench.plugins) { if (typeof p.onCompleteBenchmark === 'function') { - p.onCompleteBenchmark(result); + p.onCompleteBenchmark(result, bench); } } diff --git a/lib/lifecycle.js b/lib/lifecycle.js index d59c74a..46cbf2d 100644 --- a/lib/lifecycle.js +++ b/lib/lifecycle.js @@ -11,13 +11,13 @@ function getItersForOpDuration(durationPerOp, targetTime) { return Math.min(Number.MAX_SAFE_INTEGER, Math.max(1, Math.round(totalOpsForMinTime))); } -function parsePluginsResult(plugins) { +function parsePluginsResult(plugins, name) { const result = [] for (const p of plugins) { result.push({ name: p.toString(), - result: p.getResult?.() ?? 'enabled', - report: p.getReport?.() ?? '', + result: p.getResult?.(name) ?? 'enabled', + report: p.getReport?.(name) ?? '', }); } return result; @@ -97,7 +97,7 @@ async function runBenchmark(bench, initialIterations) { iterations, histogram, name: bench.name, - plugins: parsePluginsResult(bench.plugins), + plugins: parsePluginsResult(bench.plugins, bench.name), }; }