Skip to content

Commit 6719f3f

Browse files
committed
Add target to runtime compare page filters
1 parent 79a6fa3 commit 6719f3f

File tree

7 files changed

+79
-30
lines changed

7 files changed

+79
-30
lines changed

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import {BenchmarkFilter, CompareResponse, StatComparison} from "../types";
1+
import {
2+
BenchmarkFilter,
3+
CompareResponse,
4+
StatComparison,
5+
TargetSet,
6+
} from "../types";
27
import {calculateComparison, TestCaseComparison} from "../data";
3-
import {benchmarkNameMatchesFilter} from "../shared";
8+
import {benchmarkNameMatchesFilter, targetMatchesFilter} from "../shared";
49

510
export type CompileBenchmarkFilter = {
611
profile: {
@@ -19,9 +24,7 @@ export type CompileBenchmarkFilter = {
1924
llvm: boolean;
2025
cranelift: boolean;
2126
};
22-
target: {
23-
x86_64_unknown_linux_gnu: boolean;
24-
};
27+
target: TargetSet;
2528
category: {
2629
primary: boolean;
2730
secondary: boolean;
@@ -160,15 +163,6 @@ export function computeCompileComparisonsWithNonRelevant(
160163
}
161164
}
162165

163-
function targetFilter(target: Target): boolean {
164-
if (target === "x86_64-unknown-linux-gnu") {
165-
return filter.target.x86_64_unknown_linux_gnu;
166-
} else {
167-
// Unknown, but by default we should show things
168-
return true;
169-
}
170-
}
171-
172166
function artifactFilter(metadata: CompileBenchmarkMetadata | null): boolean {
173167
if (metadata?.binary === null) return true;
174168

@@ -201,7 +195,7 @@ export function computeCompileComparisonsWithNonRelevant(
201195
profileFilter(comparison.testCase.profile) &&
202196
scenarioFilter(comparison.testCase.scenario) &&
203197
backendFilter(comparison.testCase.backend) &&
204-
targetFilter(comparison.testCase.target) &&
198+
targetMatchesFilter(comparison.testCase.target, filter.target) &&
205199
categoryFilter(comparison.testCase.category) &&
206200
artifactFilter(benchmarkMap[comparison.testCase.benchmark] ?? null) &&
207201
changeFilter(comparison) &&

site/frontend/src/pages/compare/compile/compile-page.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from "./common";
1919
import {BenchmarkInfo} from "../../../api";
2020
import {importantCompileMetrics} from "../metrics";
21-
import {getBoolOrDefault} from "../shared";
21+
import {getBoolOrDefault, loadTargetSetFromUrl} from "../shared";
2222
2323
const props = defineProps<{
2424
data: CompareResponse;
@@ -78,13 +78,7 @@ function loadFilterFromUrl(
7878
defaultFilter.backend.cranelift
7979
),
8080
},
81-
target: {
82-
x86_64_unknown_linux_gnu: getBoolOrDefault(
83-
urlParams,
84-
"target-x86_64-unknown-linux-gnu",
85-
defaultFilter.target.x86_64_unknown_linux_gnu
86-
),
87-
},
81+
target: loadTargetSetFromUrl(urlParams, defaultFilter.target),
8882
category: {
8983
primary: getBoolOrDefault(
9084
urlParams,

site/frontend/src/pages/compare/runtime/common.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import {BenchmarkFilter, StatComparison} from "../types";
1+
import {BenchmarkFilter, StatComparison, TargetSet} from "../types";
22
import {calculateComparison, TestCaseComparison} from "../data";
3-
import {benchmarkNameMatchesFilter} from "../shared";
3+
import {benchmarkNameMatchesFilter, targetMatchesFilter} from "../shared";
44
import {Target} from "../compile/common";
55

66
export interface RuntimeTestCase {
77
benchmark: string;
88
target: Target;
99
}
1010

11-
export type RuntimeBenchmarkFilter = BenchmarkFilter;
11+
export type RuntimeBenchmarkFilter = {
12+
target: TargetSet;
13+
} & BenchmarkFilter;
1214

1315
export const defaultRuntimeFilter: RuntimeBenchmarkFilter = {
1416
name: null,
1517
nonRelevant: false,
1618
showRawData: false,
19+
target: {
20+
x86_64_unknown_linux_gnu: true,
21+
},
1722
};
1823

1924
export interface RuntimeBenchmarkComparison {
@@ -29,9 +34,9 @@ export function computeRuntimeComparisonsWithNonRelevant(
2934
function shouldShowTestCase(
3035
comparison: TestCaseComparison<RuntimeTestCase>
3136
): boolean {
32-
return benchmarkNameMatchesFilter(
33-
comparison.testCase.benchmark,
34-
filter.name
37+
return (
38+
benchmarkNameMatchesFilter(comparison.testCase.benchmark, filter.name) &&
39+
targetMatchesFilter(comparison.testCase.target, filter.target)
3540
);
3641
}
3742

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ const opened = createPersistedRef(PREF_FILTERS_OPENED);
4545
<div class="section-heading">Filter</div>
4646
<input id="filter" type="text" v-model="filter.name" />
4747
</div>
48+
<div class="section section-list-wrapper">
49+
<div class="section-heading">
50+
<div style="width: 160px">
51+
<span>Targets</span>
52+
<Tooltip>The target of the compiled benchmark. </Tooltip>
53+
</div>
54+
</div>
55+
<ul class="states-list">
56+
<li>
57+
<label>
58+
<input
59+
type="checkbox"
60+
v-model="filter.target.x86_64_unknown_linux_gnu"
61+
/>
62+
<span class="label">x86_64-unknown-linux-gnu</span>
63+
</label>
64+
<Tooltip>The default Linux x64 target.</Tooltip>
65+
</li>
66+
</ul>
67+
</div>
4868
<div class="section">
4969
<div class="section-heading">
5070
<span>Show non-relevant results</span>

site/frontend/src/pages/compare/runtime/runtime-page.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import MetricSelector from "../metric-selector.vue";
1212
import {BenchmarkInfo} from "../../../api";
1313
import {importantRuntimeMetrics} from "../metrics";
1414
import ComparisonsTable from "./comparisons-table.vue";
15-
import {getBoolOrDefault} from "../shared";
15+
import {getBoolOrDefault, loadTargetSetFromUrl} from "../shared";
1616
import {changeUrl, getUrlParams} from "../../../utils/navigation";
1717
import Filters from "./filters.vue";
1818
@@ -28,6 +28,7 @@ function loadFilterFromUrl(
2828
): RuntimeBenchmarkFilter {
2929
return {
3030
name: urlParams["runtimeName"] ?? defaultFilter.name,
31+
target: loadTargetSetFromUrl(urlParams, defaultFilter.target),
3132
nonRelevant: getBoolOrDefault(
3233
urlParams,
3334
"nonRelevant",
@@ -65,6 +66,11 @@ function storeFilterToUrl(
6566
}
6667
6768
storeOrReset("runtimeName", filter.name || null, defaultFilter.name);
69+
storeOrReset(
70+
"target-x86_64-unknown-linux-gnu",
71+
filter.target.x86_64_unknown_linux_gnu,
72+
defaultFilter.target.x86_64_unknown_linux_gnu
73+
);
6874
storeOrReset("nonRelevant", filter.nonRelevant, defaultFilter.nonRelevant);
6975
storeOrReset("showRawData", filter.showRawData, defaultFilter.showRawData);
7076
changeUrl(urlParams);

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {Target} from "./compile/common";
2+
import {TargetSet} from "./types";
23

34
export function formatDate(dateString: string): string {
45
const date = new Date(dateString);
@@ -96,6 +97,31 @@ export function benchmarkNameMatchesFilter(
9697
}
9798
}
9899

100+
export function targetMatchesFilter(
101+
target: Target,
102+
target_set: TargetSet
103+
): boolean {
104+
if (target === "x86_64-unknown-linux-gnu") {
105+
return target_set.x86_64_unknown_linux_gnu;
106+
} else {
107+
// Unknown, but by default we should show things
108+
return true;
109+
}
110+
}
111+
112+
export function loadTargetSetFromUrl(
113+
urlParams: Dict<string>,
114+
defaultTargetSet: TargetSet
115+
): TargetSet {
116+
return {
117+
x86_64_unknown_linux_gnu: getBoolOrDefault(
118+
urlParams,
119+
"target-x86_64-unknown-linux-gnu",
120+
defaultTargetSet.x86_64_unknown_linux_gnu
121+
),
122+
};
123+
}
124+
99125
const TARGET_SHORTCUTS: {[target in Target]: string} = {
100126
"x86_64-unknown-linux-gnu": "x64",
101127
};

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ export enum Tab {
5757
Bootstrap = "bootstrap",
5858
ArtifactSize = "artifact-size",
5959
}
60+
61+
export interface TargetSet {
62+
x86_64_unknown_linux_gnu: boolean;
63+
}

0 commit comments

Comments
 (0)