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

Commit d77228a

Browse files
committed
Add quick metrics switcher to compile page
1 parent ebbf2de commit d77228a

File tree

5 files changed

+114
-79
lines changed

5 files changed

+114
-79
lines changed

site/frontend/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export interface BenchmarkInfo {
88
as_of: string | null;
99
}
1010

11-
export async function loadBenchmarkInfo() {
11+
export async function loadBenchmarkInfo(): Promise<BenchmarkInfo> {
1212
return await getJson<BenchmarkInfo>(INFO_URL);
1313
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import QuickLinks from "./quick-links.vue";
2+
import MetricSelector from "../metric-selector.vue";
33
import Filters from "./filters.vue";
44
import OverallSummary from "../summary/overall-summary.vue";
55
import Aggregations from "./aggregations.vue";
@@ -15,10 +15,12 @@ import {
1515
createCompileBenchmarkMap,
1616
defaultCompileFilter,
1717
} from "./common";
18+
import {BenchmarkInfo} from "../../../api";
1819
1920
const props = defineProps<{
2021
data: CompareResponse;
2122
selector: CompareSelector;
23+
benchmarkInfo: BenchmarkInfo;
2224
}>();
2325
2426
function loadFilterFromUrl(
@@ -164,7 +166,11 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
164166
</script>
165167

166168
<template>
167-
<QuickLinks :stat="selector.stat" :key="quickLinksKey" />
169+
<MetricSelector
170+
:metric="selector.stat"
171+
:key="quickLinksKey"
172+
:benchmark-info="benchmarkInfo"
173+
/>
168174
<Filters
169175
:defaultFilter="defaultCompileFilter"
170176
:initialFilter="filter"

site/frontend/src/pages/compare/compile/quick-links.vue

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<script setup lang="ts">
2+
import {
3+
createUrlWithAppendedParams,
4+
navigateToUrlParams,
5+
} from "../../utils/navigation";
6+
import {BenchmarkInfo} from "../../api";
7+
8+
const props = defineProps<{
9+
metric: string;
10+
benchmarkInfo: BenchmarkInfo;
11+
}>();
12+
13+
function createMetric(
14+
label: string,
15+
metric: string,
16+
description: string
17+
): {
18+
label: string;
19+
metric: string;
20+
description: string;
21+
} {
22+
return {label, metric, description};
23+
}
24+
25+
function createUrlForMetric(metric: string): URL {
26+
const params = {stat: metric};
27+
return createUrlWithAppendedParams(params);
28+
}
29+
30+
function changeMetric(e: Event) {
31+
const target = e.target as HTMLSelectElement;
32+
const metric = target.value;
33+
navigateToUrlParams(createUrlForMetric(metric).searchParams);
34+
}
35+
36+
const metrics = [
37+
createMetric(
38+
"Instructions",
39+
"instructions:u",
40+
"Number of executed instructions"
41+
),
42+
createMetric("Cycles", "cycles:u", "Number of executed cycles"),
43+
createMetric("Wall time", "wall-time", "Wall time"),
44+
createMetric("Max RSS", "max-rss", "Peak memory usage (resident set size)"),
45+
createMetric(
46+
"Binary size",
47+
"size:linked_artifact",
48+
"Size of the generated binary artifact"
49+
),
50+
];
51+
</script>
52+
53+
<template>
54+
<div class="wrapper">
55+
<div class="label">Select metric:</div>
56+
<div
57+
v-for="metric in metrics"
58+
:class="{active: props.metric === metric.metric}"
59+
:title="metric.description"
60+
>
61+
<a :href="createUrlForMetric(metric.metric).toString()">{{
62+
metric.label
63+
}}</a>
64+
</div>
65+
<select class="stats" @change="changeMetric">
66+
<option
67+
v-for="value in benchmarkInfo.stats"
68+
:value="value"
69+
:selected="value === metric"
70+
>
71+
{{ value }}
72+
</option>
73+
</select>
74+
</div>
75+
</template>
76+
77+
<style scoped lang="scss">
78+
.wrapper {
79+
display: flex;
80+
flex-direction: row;
81+
align-items: center;
82+
margin: 10px 0;
83+
84+
div {
85+
margin-right: 10px;
86+
}
87+
88+
.active {
89+
font-weight: bold;
90+
}
91+
92+
.label {
93+
display: none;
94+
95+
@media (min-width: 600px) {
96+
display: block;
97+
}
98+
}
99+
}
100+
</style>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ loadCompareData(selector, loading);
156156
:runtime-summary="runtimeSummary"
157157
/>
158158
<template v-if="activeTab === Tab.CompileTime">
159-
<CompileBenchmarksPage :data="data" :selector="selector" />
159+
<CompileBenchmarksPage
160+
:data="data"
161+
:selector="selector"
162+
:benchmark-info="info"
163+
/>
160164
</template>
161165
<BootstrapTable v-if="activeTab === Tab.Bootstrap" :data="data" />
162166
<template v-if="runtimeDataAvailable && activeTab === Tab.Runtime">

0 commit comments

Comments
 (0)