Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 74a6505

Browse files
committed
Generalize test case
1 parent 0c7169a commit 74a6505

File tree

5 files changed

+121
-95
lines changed

5 files changed

+121
-95
lines changed

site/frontend/src/pages/compare/benchmarks/benchmarks.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script setup lang="tsx">
22
import {computed, h} from "vue";
33
import TestCasesTable from "./test-cases-table.vue";
4-
import {TestCase} from "../data";
4+
import {CompileTestCase, TestCaseComparison} from "../data";
55
import {CompareResponse, CompileBenchmarkFilter} from "../types";
66
77
export interface BenchmarkProps {
88
data: CompareResponse;
9-
testCases: TestCase[];
10-
allTestCases: TestCase[];
9+
testCases: TestCaseComparison<CompileTestCase>[];
10+
allTestCases: TestCaseComparison<CompileTestCase>[];
1111
filter: CompileBenchmarkFilter;
1212
stat: string;
1313
}
@@ -35,16 +35,20 @@ function Section({
3535
}
3636
3737
const primaryCases = computed(() =>
38-
props.testCases.filter((c) => c.category === "primary")
38+
props.testCases.filter((c) => c.testCase.category === "primary")
3939
);
4040
const secondaryCases = computed(() =>
41-
props.testCases.filter((c) => c.category === "secondary")
41+
props.testCases.filter((c) => c.testCase.category === "secondary")
4242
);
4343
const primaryHasNonRelevant = computed(
44-
() => props.allTestCases.filter((c) => c.category === "primary").length > 0
44+
() =>
45+
props.allTestCases.filter((c) => c.testCase.category === "primary").length >
46+
0
4547
);
4648
const secondaryHasNonRelevant = computed(
47-
() => props.allTestCases.filter((c) => c.category === "secondary").length > 0
49+
() =>
50+
props.allTestCases.filter((c) => c.testCase.category === "secondary")
51+
.length > 0
4852
);
4953
</script>
5054

site/frontend/src/pages/compare/benchmarks/test-cases-table.vue

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
2-
import {TestCase} from "../data";
2+
import {CompileTestCase, TestCaseComparison} from "../data";
33
import Tooltip from "../tooltip.vue";
44
import {ArtifactDescription} from "../types";
55
import {percentClass} from "../shared";
66
77
const props = defineProps<{
88
id: string;
9-
cases: TestCase[];
9+
cases: TestCaseComparison<CompileTestCase>[];
1010
hasNonRelevant: boolean;
1111
showRawData: boolean;
1212
commitA: ArtifactDescription;
@@ -21,7 +21,7 @@ function benchmarkLink(benchmark: string): string {
2121
function graphLink(
2222
commit: ArtifactDescription,
2323
stat: string,
24-
testCase: TestCase
24+
comparison: TestCaseComparison<CompileTestCase>
2525
): string {
2626
let date = new Date(commit.date);
2727
// Move to `30 days ago` to display history of the test case
@@ -32,22 +32,22 @@ function graphLink(
3232
let start = `${year}-${month}-${day}`;
3333
3434
let end = commit.commit;
35-
return `/index.html?start=${start}&end=${end}&benchmark=${testCase.benchmark}&profile=${testCase.profile}&scenario=${testCase.scenario}&stat=${stat}`;
35+
return `/index.html?start=${start}&end=${end}&benchmark=${comparison.testCase.benchmark}&profile=${comparison.testCase.profile}&scenario=${comparison.testCase.scenario}&stat=${stat}`;
3636
}
3737
3838
function detailedQueryPercentLink(
3939
commit: ArtifactDescription,
4040
baseCommit: ArtifactDescription,
41-
testCase: TestCase
41+
comparison: TestCaseComparison<CompileTestCase>
4242
): string {
43-
return `/detailed-query.html?commit=${commit.commit}&base_commit=${baseCommit.commit}&benchmark=${testCase.benchmark}-${testCase.profile}&scenario=${testCase.scenario}`;
43+
return `/detailed-query.html?commit=${commit.commit}&base_commit=${baseCommit.commit}&benchmark=${comparison.testCase.benchmark}-${comparison.testCase.profile}&scenario=${comparison.testCase.scenario}`;
4444
}
4545
4646
function detailedQueryRawDataLink(
4747
commit: ArtifactDescription,
48-
testCase: TestCase
48+
comparison: TestCaseComparison<CompileTestCase>
4949
) {
50-
return `/detailed-query.html?commit=${commit.commit}&benchmark=${testCase.benchmark}-${testCase.profile}&scenario=${testCase.scenario}`;
50+
return `/detailed-query.html?commit=${commit.commit}&benchmark=${comparison.testCase.benchmark}-${comparison.testCase.profile}&scenario=${comparison.testCase.scenario}`;
5151
}
5252
5353
function prettifyRawNumber(number: number): string {
@@ -95,37 +95,37 @@ function prettifyRawNumber(number: number): string {
9595
</tr>
9696
</thead>
9797
<tbody>
98-
<template v-for="testCase in cases">
98+
<template v-for="comparison in cases">
9999
<tr>
100100
<td>
101101
<a
102-
v-bind:href="benchmarkLink(testCase.benchmark)"
102+
v-bind:href="benchmarkLink(comparison.testCase.benchmark)"
103103
class="silent-link"
104104
target="_blank"
105105
>
106-
{{ testCase.benchmark }}
106+
{{ comparison.testCase.benchmark }}
107107
</a>
108108
</td>
109109
<td>
110110
<a
111-
v-bind:href="graphLink(commitB, stat, testCase)"
111+
v-bind:href="graphLink(commitB, stat, comparison)"
112112
target="_blank"
113113
class="silent-link"
114114
>
115-
{{ testCase.profile }}
115+
{{ comparison.testCase.profile }}
116116
</a>
117117
</td>
118-
<td>{{ testCase.scenario }}</td>
118+
<td>{{ comparison.testCase.scenario }}</td>
119119
<td>
120120
<div class="numeric-aligned">
121121
<div>
122122
<a
123123
v-bind:href="
124-
detailedQueryPercentLink(commitB, commitA, testCase)
124+
detailedQueryPercentLink(commitB, commitA, comparison)
125125
"
126126
>
127-
<span v-bind:class="percentClass(testCase.percent)">
128-
{{ testCase.percent.toFixed(2) }}%
127+
<span v-bind:class="percentClass(comparison.percent)">
128+
{{ comparison.percent.toFixed(2) }}%
129129
</span>
130130
</a>
131131
</div>
@@ -135,8 +135,8 @@ function prettifyRawNumber(number: number): string {
135135
<div class="numeric-aligned">
136136
<div>
137137
{{
138-
testCase.significanceThreshold
139-
? testCase.significanceThreshold.toFixed(2) + "%"
138+
comparison.significanceThreshold
139+
? comparison.significanceThreshold.toFixed(2) + "%"
140140
: "-"
141141
}}
142142
</div>
@@ -146,24 +146,24 @@ function prettifyRawNumber(number: number): string {
146146
<div class="numeric-aligned">
147147
<div>
148148
{{
149-
testCase.significanceFactor
150-
? testCase.significanceFactor.toFixed(2) + "x"
149+
comparison.significanceFactor
150+
? comparison.significanceFactor.toFixed(2) + "x"
151151
: "-"
152152
}}
153153
</div>
154154
</div>
155155
</td>
156156
<td v-if="showRawData" class="numeric">
157-
<a v-bind:href="detailedQueryRawDataLink(commitA, testCase)">
158-
<abbr :title="testCase.datumA">{{
159-
prettifyRawNumber(testCase.datumA)
157+
<a v-bind:href="detailedQueryRawDataLink(commitA, comparison)">
158+
<abbr :title="comparison.datumA">{{
159+
prettifyRawNumber(comparison.datumA)
160160
}}</abbr>
161161
</a>
162162
</td>
163163
<td v-if="showRawData" class="numeric">
164-
<a v-bind:href="detailedQueryRawDataLink(commitB, testCase)">
165-
<abbr :title="testCase.datumB">{{
166-
prettifyRawNumber(testCase.datumB)
164+
<a v-bind:href="detailedQueryRawDataLink(commitB, comparison)">
165+
<abbr :title="comparison.datumB">{{
166+
prettifyRawNumber(comparison.datumB)
167167
}}</abbr>
168168
</a>
169169
</td>

site/frontend/src/pages/compare/compile/export.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import {computeSummary, TestCase} from "../data";
1+
import {CompileTestCase, computeSummary, TestCaseComparison} from "../data";
22

3-
export function exportToMarkdown(testCases: TestCase[]) {
4-
function changesTable(cases) {
3+
export function exportToMarkdown(
4+
comparisons: TestCaseComparison<CompileTestCase>[]
5+
) {
6+
function changesTable(comparisons: TestCaseComparison<CompileTestCase>[]) {
57
let data =
68
"| Benchmark | Profile | Scenario | % Change | Significance Factor |\n";
79
data += "|:---:|:---:|:---:|:---:|:---:|\n";
810

9-
for (const testCase of cases) {
10-
data += `| ${testCase.benchmark} | ${testCase.profile} | ${testCase.scenario} `;
11-
data += `| ${testCase.percent.toFixed(
11+
for (const comparison of comparisons) {
12+
data += `| ${comparison.testCase.benchmark} | ${comparison.testCase.profile} | ${comparison.testCase.scenario} `;
13+
data += `| ${comparison.percent.toFixed(
1214
2
13-
)}% | ${testCase.significanceFactor.toFixed(2)}x\n`;
15+
)}% | ${comparison.significanceFactor.toFixed(2)}x\n`;
1416
}
1517

1618
return data;
1719
}
1820

19-
const summary = computeSummary(testCases);
21+
const summary = computeSummary(comparisons);
2022
const regressions = summary.regressions;
2123
const improvements = summary.improvements;
2224
const all = summary.all;
@@ -43,12 +45,12 @@ export function exportToMarkdown(testCases: TestCase[]) {
4345

4446
content += "# Primary benchmarks\n";
4547
content += changesTable(
46-
testCases.filter((testCase) => testCase.category === "primary")
48+
comparisons.filter((testCase) => testCase.testCase.category === "primary")
4749
);
4850

4951
content += "\n# Secondary benchmarks\n";
5052
content += changesTable(
51-
testCases.filter((testCase) => testCase.category === "secondary")
53+
comparisons.filter((testCase) => testCase.testCase.category === "secondary")
5254
);
5355

5456
downloadFile(content, "perf-summary.md");

0 commit comments

Comments
 (0)