Skip to content

Commit

Permalink
feat: add enough context to plugin methods to figure out bench task name
Browse files Browse the repository at this point in the history
  • Loading branch information
naugtur authored and RafaelGSS committed Nov 16, 2024
1 parent fd379d6 commit c16cf34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,7 +97,7 @@ async function runBenchmark(bench, initialIterations) {
iterations,
histogram,
name: bench.name,
plugins: parsePluginsResult(bench.plugins),
plugins: parsePluginsResult(bench.plugins, bench.name),
};
}

Expand Down

0 comments on commit c16cf34

Please sign in to comment.