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

Commit 0c7169a

Browse files
committed
Add runtime benchmarks tab
1 parent 837e406 commit 0c7169a

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

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

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
getUrlParams,
88
navigateToUrlParams,
99
} from "../../utils/navigation";
10-
import {Ref, ref} from "vue";
10+
import {computed, Ref, ref} from "vue";
1111
import {withLoading} from "../../utils/loading";
1212
import {postMsgpack} from "../../utils/requests";
1313
import {COMPARE_DATA_URL} from "../../urls";
@@ -39,12 +39,12 @@ function loadSelectorFromUrl(urlParams: Dict<string>): CompareSelector {
3939
4040
function loadTabFromUrl(urlParams: Dict<string>): Tab | null {
4141
const tab = urlParams["tab"] ?? "";
42-
if (tab == Tab.CompileTime) {
43-
return Tab.CompileTime;
44-
} else if (tab == Tab.Bootstrap) {
45-
return Tab.Bootstrap;
46-
}
47-
return null;
42+
const tabs = {
43+
compile: Tab.CompileTime,
44+
runtime: Tab.Runtime,
45+
bootstrap: Tab.Bootstrap,
46+
};
47+
return tabs[tab] ?? null;
4848
}
4949
5050
function storeTabToUrl(urlParams: Dict<string>, tab: Tab) {
@@ -56,24 +56,27 @@ async function loadCompareData(
5656
selector: CompareSelector,
5757
loading: Ref<boolean>
5858
) {
59-
data.value = await withLoading(loading, async () => {
59+
const response = await withLoading(loading, async () => {
6060
const params = {
6161
start: selector.start,
6262
end: selector.end,
6363
stat: selector.stat,
6464
};
6565
return await postMsgpack<CompareResponse>(COMPARE_DATA_URL, params);
6666
});
67+
data.value = response;
68+
6769
compileSummary.value = computeSummary(
6870
filterNonRelevant(
6971
defaultCompileFilter,
7072
computeTestCasesWithNonRelevant(
7173
defaultCompileFilter,
72-
data.value,
73-
createCompileBenchmarkMap(data.value)
74+
response,
75+
createCompileBenchmarkMap(response)
7476
)
7577
)
7678
);
79+
runtimeDataAvailable.value = response.runtime_comparisons.length > 0;
7780
}
7881
7982
function updateSelection(params: SelectionParams) {
@@ -88,7 +91,7 @@ function updateSelection(params: SelectionParams) {
8891
8992
const urlParams = getUrlParams();
9093
91-
// Include all relevant changes in the compile-time tab summary
94+
// Include all relevant changes in the compile-time tab summary.
9295
// We do not wrap it in computed, because it should be loaded only once, after
9396
// the data is downloaded.
9497
const compileSummary: Ref<SummaryGroup | null> = ref(null);
@@ -100,6 +103,14 @@ const selector = loadSelectorFromUrl(urlParams);
100103
101104
const initialTab: Tab = loadTabFromUrl(urlParams) ?? Tab.CompileTime;
102105
const tab: Ref<Tab> = ref(initialTab);
106+
const activeTab = computed((): Tab => {
107+
if (tab.value === Tab.Runtime && !runtimeDataAvailable.value) {
108+
return Tab.CompileTime;
109+
}
110+
return tab.value;
111+
});
112+
113+
const runtimeDataAvailable = ref(false);
103114
104115
function changeTab(newTab: Tab) {
105116
tab.value = newTab;
@@ -130,10 +141,13 @@ loadCompareData(selector, loading);
130141
:initial-tab="initialTab"
131142
:compile-time-summary="compileSummary"
132143
/>
133-
<template v-if="tab === Tab.CompileTime">
144+
<template v-if="activeTab === Tab.CompileTime">
134145
<CompileBenchmarksPage :data="data" :selector="selector" />
135146
</template>
136-
<BootstrapTable v-if="tab === Tab.Bootstrap" :data="data" />
147+
<BootstrapTable v-if="activeTab === Tab.Bootstrap" :data="data" />
148+
<template v-if="runtimeDataAvailable && activeTab === Tab.Runtime">
149+
Runtime data
150+
</template>
137151
</div>
138152
</div>
139153
<br />

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const activeTab: Ref<Tab> = ref(props.initialTab);
4646
<div class="wrapper">
4747
<div
4848
class="tab"
49-
title="Compilation time benchmarks"
49+
title="Compilation time benchmarks: measure how long does it take to compile various crates using the compared rustc."
5050
:class="{selected: activeTab === Tab.CompileTime}"
5151
@click="changeTab(Tab.CompileTime)"
5252
>
@@ -80,7 +80,16 @@ const activeTab: Ref<Tab> = ref(props.initialTab);
8080
</div>
8181
<div
8282
class="tab"
83-
title="Bootstrap duration"
83+
title="Runtime benchmarks: measure how long does it take to execute (i.e. how fast are) programs compiled by the compared rustc."
84+
:class="{selected: activeTab === Tab.Runtime}"
85+
@click="changeTab(Tab.Runtime)"
86+
>
87+
<div class="title">Runtime</div>
88+
<div class="summary runtime"></div>
89+
</div>
90+
<div
91+
class="tab"
92+
title="Bootstrap duration: measures how long does it take to compile rustc by itself."
8493
:class="{selected: activeTab === Tab.Bootstrap}"
8594
@click="changeTab(Tab.Bootstrap)"
8695
>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ export interface CompareResponse {
7474

7575
export enum Tab {
7676
CompileTime = "compile",
77+
Runtime = "runtime",
7778
Bootstrap = "bootstrap",
7879
}

site/frontend/src/utils/requests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function getJson<T>(
2828
return await response.json();
2929
}
3030

31-
export async function postMsgpack(path: string, body: any) {
31+
export async function postMsgpack<T>(path: string, body: any): Promise<T> {
3232
const response = await fetch(path, {
3333
method: "POST",
3434
body: JSON.stringify(body),

0 commit comments

Comments
 (0)