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

Commit 837e406

Browse files
committed
Move compile-time related components to a separate compile-time page
1 parent 311d5f9 commit 837e406

File tree

7 files changed

+234
-204
lines changed

7 files changed

+234
-204
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import {computed, h} from "vue";
33
import TestCasesTable from "./test-cases-table.vue";
44
import {TestCase} from "../data";
5-
import {CompareResponse, DataFilter} from "../types";
5+
import {CompareResponse, CompileBenchmarkFilter} from "../types";
66
77
export interface BenchmarkProps {
88
data: CompareResponse;
99
testCases: TestCase[];
1010
allTestCases: TestCase[];
11-
filter: DataFilter;
11+
filter: CompileBenchmarkFilter;
1212
stat: string;
1313
}
1414
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {CompileBenchmarkFilter} from "../types";
2+
3+
export const defaultFilter: CompileBenchmarkFilter = {
4+
name: null,
5+
nonRelevant: false,
6+
showRawData: false,
7+
profile: {
8+
check: true,
9+
debug: true,
10+
opt: true,
11+
doc: true,
12+
},
13+
scenario: {
14+
full: true,
15+
incrFull: true,
16+
incrUnchanged: true,
17+
incrPatched: true,
18+
},
19+
category: {
20+
primary: true,
21+
secondary: true,
22+
},
23+
};

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import Toggle from "../toggle.vue";
3-
import {DataFilter} from "../types";
3+
import {CompileBenchmarkFilter} from "../types";
44
import Tooltip from "../tooltip.vue";
55
import {ref, toRaw, watch} from "vue";
66
import {deepCopy} from "../../../utils/copy";
@@ -9,12 +9,12 @@ import {createPersistedRef} from "../../../storage";
99
1010
const props = defineProps<{
1111
// When reset, set filter to this value
12-
defaultFilter: DataFilter;
12+
defaultFilter: CompileBenchmarkFilter;
1313
// Initialize the filter with this value
14-
initialFilter: DataFilter;
14+
initialFilter: CompileBenchmarkFilter;
1515
}>();
1616
const emit = defineEmits<{
17-
(e: "change", filter: DataFilter): void;
17+
(e: "change", filter: CompileBenchmarkFilter): void;
1818
(e: "export"): void;
1919
}>();
2020
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<script setup lang="ts">
2+
import QuickLinks from "./quick-links.vue";
3+
import Filters from "./filters.vue";
4+
import OverallTable from "../summary/overall-table.vue";
5+
import Aggregations from "../summary/aggregations.vue";
6+
import Benchmarks from "../benchmarks/benchmarks.vue";
7+
import {
8+
CompareResponse,
9+
CompareSelector,
10+
CompileBenchmarkFilter,
11+
} from "../types";
12+
import {computed, ref} from "vue";
13+
import {changeUrl, getUrlParams} from "../../../utils/navigation";
14+
import {exportToMarkdown} from "./export";
15+
import {
16+
createCompileBenchmarkMap,
17+
computeSummary,
18+
computeTestCasesWithNonRelevant,
19+
filterNonRelevant,
20+
} from "../data";
21+
import {defaultFilter} from "./common";
22+
23+
const props = defineProps<{
24+
data: CompareResponse;
25+
selector: CompareSelector;
26+
}>();
27+
28+
function loadFilterFromUrl(
29+
urlParams: Dict<string>,
30+
defaultFilter: CompileBenchmarkFilter
31+
): CompileBenchmarkFilter {
32+
function getBoolOrDefault(name: string, defaultValue: boolean): boolean {
33+
if (urlParams.hasOwnProperty(name)) {
34+
return urlParams[name] === "true";
35+
}
36+
return defaultValue;
37+
}
38+
39+
return {
40+
name: urlParams["name"] ?? defaultFilter.name,
41+
nonRelevant: getBoolOrDefault("nonRelevant", defaultFilter.nonRelevant),
42+
showRawData: getBoolOrDefault("showRawData", defaultFilter.showRawData),
43+
profile: {
44+
check: getBoolOrDefault("check", defaultFilter.profile.check),
45+
debug: getBoolOrDefault("debug", defaultFilter.profile.debug),
46+
opt: getBoolOrDefault("opt", defaultFilter.profile.opt),
47+
doc: getBoolOrDefault("doc", defaultFilter.profile.doc),
48+
},
49+
scenario: {
50+
full: getBoolOrDefault("full", defaultFilter.scenario.full),
51+
incrFull: getBoolOrDefault("incrFull", defaultFilter.scenario.incrFull),
52+
incrUnchanged: getBoolOrDefault(
53+
"incrUnchanged",
54+
defaultFilter.scenario.incrUnchanged
55+
),
56+
incrPatched: getBoolOrDefault(
57+
"incrPatched",
58+
defaultFilter.scenario.incrPatched
59+
),
60+
},
61+
category: {
62+
primary: getBoolOrDefault("primary", defaultFilter.category.primary),
63+
secondary: getBoolOrDefault(
64+
"secondary",
65+
defaultFilter.category.secondary
66+
),
67+
},
68+
};
69+
}
70+
71+
/**
72+
* Stores the given filter parameters into URL, so that the current "view" can be shared with
73+
* others easily.
74+
*/
75+
function storeFilterToUrl(
76+
filter: CompileBenchmarkFilter,
77+
defaultFilter: CompileBenchmarkFilter,
78+
urlParams: Dict<string>
79+
) {
80+
function storeOrReset<T extends boolean | string>(
81+
name: string,
82+
value: T,
83+
defaultValue: T
84+
) {
85+
if (value === defaultValue) {
86+
if (urlParams.hasOwnProperty(name)) {
87+
delete urlParams[name];
88+
}
89+
} else {
90+
urlParams[name] = value.toString();
91+
}
92+
}
93+
94+
storeOrReset("name", filter.name || null, defaultFilter.name);
95+
storeOrReset("nonRelevant", filter.nonRelevant, defaultFilter.nonRelevant);
96+
storeOrReset("showRawData", filter.showRawData, defaultFilter.showRawData);
97+
storeOrReset("check", filter.profile.check, defaultFilter.profile.check);
98+
storeOrReset("debug", filter.profile.debug, defaultFilter.profile.debug);
99+
storeOrReset("opt", filter.profile.opt, defaultFilter.profile.opt);
100+
storeOrReset("doc", filter.profile.doc, defaultFilter.profile.doc);
101+
storeOrReset("full", filter.scenario.full, defaultFilter.scenario.full);
102+
storeOrReset(
103+
"incrFull",
104+
filter.scenario.incrFull,
105+
defaultFilter.scenario.incrFull
106+
);
107+
storeOrReset(
108+
"incrUnchanged",
109+
filter.scenario.incrUnchanged,
110+
defaultFilter.scenario.incrUnchanged
111+
);
112+
storeOrReset(
113+
"incrPatched",
114+
filter.scenario.incrPatched,
115+
defaultFilter.scenario.incrPatched
116+
);
117+
storeOrReset(
118+
"primary",
119+
filter.category.primary,
120+
defaultFilter.category.primary
121+
);
122+
storeOrReset(
123+
"secondary",
124+
filter.category.secondary,
125+
defaultFilter.category.secondary
126+
);
127+
128+
changeUrl(urlParams);
129+
}
130+
131+
/**
132+
* When the filter changes, the URL is updated.
133+
* After that happens, we want to re-render the quick links component, because
134+
* it contains links that are "relative" to the current URL. Changing this
135+
* key ref will cause it to be re-rendered.
136+
*/
137+
function refreshQuickLinks() {
138+
quickLinksKey.value += 1;
139+
}
140+
141+
function updateFilter(newFilter: CompileBenchmarkFilter) {
142+
storeFilterToUrl(newFilter, defaultFilter, getUrlParams());
143+
filter.value = newFilter;
144+
refreshQuickLinks();
145+
}
146+
147+
function exportData() {
148+
exportToMarkdown(testCases.value);
149+
}
150+
151+
const urlParams = getUrlParams();
152+
153+
const quickLinksKey = ref(0);
154+
const filter = ref(loadFilterFromUrl(urlParams, defaultFilter));
155+
156+
const benchmarkMap = createCompileBenchmarkMap(props.data);
157+
const allTestCases = computed(() =>
158+
computeTestCasesWithNonRelevant(filter.value, props.data, benchmarkMap)
159+
);
160+
const testCases = computed(() =>
161+
filterNonRelevant(filter.value, allTestCases.value)
162+
);
163+
const filteredSummary = computed(() => computeSummary(testCases.value));
164+
</script>
165+
166+
<template>
167+
<QuickLinks :stat="selector.stat" :key="quickLinksKey" />
168+
<Filters
169+
:defaultFilter="defaultFilter"
170+
:initialFilter="filter"
171+
@change="updateFilter"
172+
@export="exportData"
173+
/>
174+
<OverallTable :summary="filteredSummary" />
175+
<Aggregations :cases="testCases" />
176+
<Benchmarks
177+
:data="data"
178+
:test-cases="testCases"
179+
:all-test-cases="allTestCases"
180+
:filter="filter"
181+
:stat="selector.stat"
182+
></Benchmarks>
183+
</template>

site/frontend/src/pages/compare/data.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
2-
BenchmarkMap,
2+
CompileBenchmarkMap,
33
Category,
44
CompareResponse,
55
CompileBenchmarkComparison,
6-
DataFilter,
6+
CompileBenchmarkFilter,
77
Profile,
88
} from "./types";
99

@@ -34,9 +34,9 @@ export interface TestCase {
3434
}
3535

3636
export function computeTestCasesWithNonRelevant(
37-
filter: DataFilter,
37+
filter: CompileBenchmarkFilter,
3838
data: CompareResponse,
39-
benchmarkMap: BenchmarkMap
39+
benchmarkMap: CompileBenchmarkMap
4040
): TestCase[] {
4141
function profileFilter(profile: Profile): boolean {
4242
if (profile === "check") {
@@ -131,7 +131,7 @@ export function computeTestCasesWithNonRelevant(
131131
}
132132

133133
export function filterNonRelevant(
134-
filter: DataFilter,
134+
filter: CompileBenchmarkFilter,
135135
cases: TestCase[]
136136
): TestCase[] {
137137
if (filter.nonRelevant) {
@@ -200,11 +200,9 @@ export function computeSummary(testCases: TestCase[]): SummaryGroup {
200200
};
201201
}
202202

203-
export function computeBenchmarkMap(
204-
data: CompareResponse | null
205-
): BenchmarkMap {
206-
if (data === null) return {};
207-
203+
export function createCompileBenchmarkMap(
204+
data: CompareResponse
205+
): CompileBenchmarkMap {
208206
const benchmarks = {};
209207
for (const benchmark of data.compile_benchmark_data) {
210208
benchmarks[benchmark.name] = {

0 commit comments

Comments
 (0)