Skip to content

Commit 65eb109

Browse files
authored
Merge pull request #1689 from Kobzol/benchmark-detail
Add benchmark detail to compile benchmark in compare page
2 parents 9a87eb4 + 7a0469b commit 65eb109

File tree

4 files changed

+163
-51
lines changed

4 files changed

+163
-51
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="tsx">
22
import {computed, h} from "vue";
3-
import ComparisonsTable from "./comparisons-table.vue";
3+
import ComparisonsTable from "./table/comparisons-table.vue";
44
import {TestCaseComparison} from "../data";
55
import {CompareResponse} from "../types";
66
import {
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<script setup lang="ts">
2+
import {
3+
CargoProfileMetadata,
4+
CompileBenchmarkMap,
5+
CompileBenchmarkMetadata,
6+
CompileTestCase,
7+
} from "../common";
8+
import {computed} from "vue";
9+
import Tooltip from "../../tooltip.vue";
10+
11+
const props = defineProps<{
12+
testCase: CompileTestCase;
13+
benchmarkMap: CompileBenchmarkMap;
14+
}>();
15+
const metadata = computed(
16+
(): CompileBenchmarkMetadata =>
17+
props.benchmarkMap[props.testCase.benchmark] ?? null
18+
);
19+
const cargoProfile = computed((): CargoProfileMetadata => {
20+
if (
21+
props.testCase.profile === "opt" &&
22+
metadata?.value.release_profile !== null
23+
) {
24+
return metadata.value.release_profile;
25+
} else if (
26+
props.testCase.profile === "debug" &&
27+
metadata?.value.dev_profile !== null
28+
) {
29+
return metadata?.value.dev_profile;
30+
}
31+
});
32+
</script>
33+
<template>
34+
<table>
35+
<tbody>
36+
<tr>
37+
<td>Benchmark</td>
38+
<td>{{ testCase.benchmark }}</td>
39+
</tr>
40+
<tr>
41+
<td>Profile</td>
42+
<td>{{ testCase.profile }}</td>
43+
</tr>
44+
<tr>
45+
<td>Scenario</td>
46+
<td>{{ testCase.scenario }}</td>
47+
</tr>
48+
<tr>
49+
<td>Category</td>
50+
<td>{{ testCase.category }}</td>
51+
</tr>
52+
<tr v-if="(metadata?.binary ?? null) !== null">
53+
<td>Artifact</td>
54+
<td>{{ metadata.binary ? "binary" : "library" }}</td>
55+
</tr>
56+
<tr v-if="(metadata?.iterations ?? null) !== null">
57+
<td>
58+
Iterations<Tooltip>
59+
How many times is the benchmark executed?
60+
</Tooltip>
61+
</td>
62+
<td>{{ metadata.iterations }}</td>
63+
</tr>
64+
<tr v-if="(cargoProfile?.lto ?? null) !== null">
65+
<td>LTO</td>
66+
<td>{{ cargoProfile.lto }}</td>
67+
</tr>
68+
<tr v-if="(cargoProfile?.debug ?? null) !== null">
69+
<td>Debuginfo</td>
70+
<td>{{ cargoProfile.debug }}</td>
71+
</tr>
72+
<tr v-if="(cargoProfile?.codegen_units ?? null) !== null">
73+
<td>Codegen units</td>
74+
<td>{{ cargoProfile.codegen_units }}</td>
75+
</tr>
76+
</tbody>
77+
</table>
78+
</template>
79+
80+
<style scoped lang="scss">
81+
table {
82+
td {
83+
text-align: left;
84+
85+
&:first-child {
86+
font-weight: bold;
87+
padding-right: 10px;
88+
}
89+
}
90+
}
91+
</style>

site/frontend/src/pages/compare/compile/comparisons-table.vue renamed to site/frontend/src/pages/compare/compile/table/comparisons-table.vue

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<script setup lang="ts">
2-
import {TestCaseComparison} from "../data";
3-
import Tooltip from "../tooltip.vue";
4-
import {ArtifactDescription} from "../types";
5-
import {percentClass} from "../shared";
6-
import {CompileBenchmarkMap, CompileTestCase} from "./common";
2+
import {TestCaseComparison} from "../../data";
3+
import Tooltip from "../../tooltip.vue";
4+
import {ArtifactDescription} from "../../types";
5+
import {percentClass} from "../../shared";
6+
import {CompileBenchmarkMap, CompileTestCase} from "../common";
77
import {computed} from "vue";
8+
import {useExpandedStore} from "./expansion";
9+
import BenchmarkDetail from "./benchmark-detail.vue";
810
911
const props = defineProps<{
1012
id: string;
@@ -60,40 +62,13 @@ function prettifyRawNumber(number: number): string {
6062
return number.toLocaleString();
6163
}
6264
63-
function generateBenchmarkTooltip(testCase: CompileTestCase): string {
64-
const metadata = props.benchmarkMap[testCase.benchmark] ?? null;
65-
if (metadata === null) {
66-
return "<No metadata found>";
65+
const columnCount = computed(() => {
66+
const base = 7;
67+
if (props.showRawData) {
68+
return base + 2;
6769
}
68-
let tooltip = `Benchmark: ${testCase.benchmark}
69-
Category: ${metadata.category}
70-
`;
71-
if (metadata.binary !== null) {
72-
tooltip += `Artifact: ${metadata.binary ? "binary" : "library"}\n`;
73-
}
74-
if (metadata.iterations !== null) {
75-
tooltip += `Iterations: ${metadata.iterations}\n`;
76-
}
77-
const addMetadata = ({lto, debug, codegen_units}) => {
78-
if (lto !== null) {
79-
tooltip += `LTO: ${lto}\n`;
80-
}
81-
if (debug !== null) {
82-
tooltip += `Debuginfo: ${debug}\n`;
83-
}
84-
if (codegen_units !== null) {
85-
tooltip += `Codegen units: ${codegen_units}\n`;
86-
}
87-
};
88-
if (testCase.profile === "opt" && metadata.release_profile !== null) {
89-
addMetadata(metadata.release_profile);
90-
} else if (testCase.profile === "debug" && metadata.dev_profile !== null) {
91-
addMetadata(metadata.dev_profile);
92-
}
93-
94-
return tooltip;
95-
}
96-
70+
return base;
71+
});
9772
const unit = computed(() => {
9873
// The DB stored wall-time data in seconds for compile benchmarks, so it is
9974
// hardcoded here
@@ -103,6 +78,7 @@ const unit = computed(() => {
10378
return null;
10479
}
10580
});
81+
const {toggleExpanded, isExpanded} = useExpandedStore();
10682
</script>
10783

10884
<template>
@@ -114,11 +90,12 @@ const unit = computed(() => {
11490
<table v-else class="benches compare">
11591
<thead>
11692
<tr>
93+
<th class="toggle"></th>
11794
<th>Benchmark</th>
11895
<th>Profile</th>
11996
<th>Scenario</th>
12097
<th>% Change</th>
121-
<th>
98+
<th class="narrow">
12299
Significance Threshold
123100
<Tooltip>
124101
The minimum % change that is considered significant. The higher
@@ -132,7 +109,7 @@ const unit = computed(() => {
132109
how the significance threshold is calculated.
133110
</Tooltip>
134111
</th>
135-
<th>
112+
<th class="narrow">
136113
Significance Factor
137114
<Tooltip>
138115
How much a particular result is over the significance threshold. A
@@ -147,7 +124,10 @@ const unit = computed(() => {
147124
<tbody>
148125
<template v-for="comparison in comparisons">
149126
<tr>
150-
<td :title="generateBenchmarkTooltip(comparison.testCase)">
127+
<td @click="toggleExpanded(comparison.testCase)" class="toggle">
128+
{{ isExpanded(comparison.testCase) ? "▼" : "▶" }}
129+
</td>
130+
<td>
151131
<a
152132
v-bind:href="benchmarkLink(comparison.testCase.benchmark)"
153133
class="silent-link"
@@ -181,7 +161,7 @@ const unit = computed(() => {
181161
</div>
182162
</div>
183163
</td>
184-
<td>
164+
<td class="narrow">
185165
<div class="numeric-aligned">
186166
<div>
187167
{{
@@ -192,7 +172,7 @@ const unit = computed(() => {
192172
</div>
193173
</div>
194174
</td>
195-
<td>
175+
<td class="narrow">
196176
<div class="numeric-aligned">
197177
<div>
198178
{{
@@ -218,6 +198,14 @@ const unit = computed(() => {
218198
</a>
219199
</td>
220200
</tr>
201+
<tr v-if="isExpanded(comparison.testCase)">
202+
<td :colspan="columnCount">
203+
<BenchmarkDetail
204+
:test-case="comparison.testCase"
205+
:benchmark-map="benchmarkMap"
206+
/>
207+
</td>
208+
</tr>
221209
</template>
222210
</tbody>
223211
</table>
@@ -226,8 +214,9 @@ const unit = computed(() => {
226214

227215
<style scoped lang="scss">
228216
.benches {
217+
width: 100%;
218+
table-layout: auto;
229219
font-size: medium;
230-
table-layout: fixed;
231220
232221
td,
233222
th {
@@ -249,15 +238,22 @@ const unit = computed(() => {
249238
border-right: dotted 1px;
250239
}
251240
252-
.benches th {
253-
text-align: center;
254-
min-width: 50px;
241+
.benches {
242+
td,
243+
th {
244+
text-align: center;
245+
246+
&.toggle {
247+
padding-right: 5px;
248+
cursor: pointer;
249+
}
250+
&.narrow {
251+
max-width: 100px;
252+
}
253+
}
255254
}
256255
257256
.benches td {
258-
text-align: center;
259-
width: 25%;
260-
261257
& > .numeric-aligned {
262258
display: flex;
263259
flex-direction: column;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {ref} from "vue";
2+
import {CompileTestCase} from "../common";
3+
4+
export function useExpandedStore() {
5+
const expanded = ref(new Set());
6+
7+
function isExpanded(testCase: CompileTestCase) {
8+
return expanded.value.has(testCaseKey(testCase));
9+
}
10+
11+
function toggleExpanded(testCase: CompileTestCase) {
12+
const key = testCaseKey(testCase);
13+
if (isExpanded(testCase)) {
14+
expanded.value.delete(key);
15+
} else {
16+
expanded.value.add(key);
17+
}
18+
}
19+
20+
return {toggleExpanded, isExpanded};
21+
}
22+
23+
function testCaseKey(testCase: CompileTestCase): string {
24+
return `${testCase.benchmark};${testCase.profile};${testCase.scenario};${testCase.category}`;
25+
}

0 commit comments

Comments
 (0)