Skip to content

Commit 6694b95

Browse files
committed
Run all the benchmarks twice
1 parent d4bf287 commit 6694b95

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

ci/perf-tester/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/perf-tester/src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { exec } from '@actions/exec';
44
import { getInput, runBenchmark, toDiff, diffTable, toBool } from './utils.js';
55

66
async function run(octokit, context, token) {
7-
const { owner, repo, number: pull_number } = context.issue;
7+
const { number: pull_number } = context.issue;
88

99
const pr = context.payload.pull_request;
1010
try {
@@ -22,7 +22,7 @@ async function run(octokit, context, token) {
2222
endGroup();
2323

2424
startGroup(`[current] Running benchmark`);
25-
const newBenchmarks = await runBenchmark();
25+
const newBenchmarks = await Promise.all([runBenchmark(), runBenchmark()]).then(averageBenchmarks);
2626
endGroup();
2727

2828
startGroup(`[base] Checkout target branch`);
@@ -62,7 +62,7 @@ async function run(octokit, context, token) {
6262
endGroup();
6363

6464
startGroup(`[base] Running benchmark`);
65-
const oldBenchmarks = await runBenchmark();
65+
const oldBenchmarks = await Promise.all([runBenchmark(), runBenchmark()]).then(averageBenchmarks);
6666
endGroup();
6767

6868
const diff = toDiff(oldBenchmarks, newBenchmarks);

ci/perf-tester/src/utils.js

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ function parse(benchmarkData) {
3636
return benchmarks
3737
}
3838

39+
export function averageBenchmarks(benchmarks) {
40+
const result = Object.create(null)
41+
for (const key of Object.keys(benchmarks[0])) {
42+
result[key] = benchmarks.reduce((acc, bench) => acc + bench[key], 0) / benchmarks.length
43+
}
44+
return result
45+
}
46+
3947
/**
4048
* @param {{[key: string]: number}} before
4149
* @param {{[key: string]: number}} after

0 commit comments

Comments
 (0)