7
7
getUrlParams ,
8
8
navigateToUrlParams ,
9
9
} from " ../../utils/navigation" ;
10
- import {Ref , ref } from " vue" ;
10
+ import {computed , Ref , ref } from " vue" ;
11
11
import {withLoading } from " ../../utils/loading" ;
12
12
import {postMsgpack } from " ../../utils/requests" ;
13
13
import {COMPARE_DATA_URL } from " ../../urls" ;
@@ -39,12 +39,12 @@ function loadSelectorFromUrl(urlParams: Dict<string>): CompareSelector {
39
39
40
40
function loadTabFromUrl(urlParams : Dict <string >): Tab | null {
41
41
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 ;
48
48
}
49
49
50
50
function storeTabToUrl(urlParams : Dict <string >, tab : Tab ) {
@@ -56,24 +56,27 @@ async function loadCompareData(
56
56
selector : CompareSelector ,
57
57
loading : Ref <boolean >
58
58
) {
59
- data . value = await withLoading (loading , async () => {
59
+ const response = await withLoading (loading , async () => {
60
60
const params = {
61
61
start: selector .start ,
62
62
end: selector .end ,
63
63
stat: selector .stat ,
64
64
};
65
65
return await postMsgpack <CompareResponse >(COMPARE_DATA_URL , params );
66
66
});
67
+ data .value = response ;
68
+
67
69
compileSummary .value = computeSummary (
68
70
filterNonRelevant (
69
71
defaultCompileFilter ,
70
72
computeTestCasesWithNonRelevant (
71
73
defaultCompileFilter ,
72
- data . value ,
73
- createCompileBenchmarkMap (data . value )
74
+ response ,
75
+ createCompileBenchmarkMap (response )
74
76
)
75
77
)
76
78
);
79
+ runtimeDataAvailable .value = response .runtime_comparisons .length > 0 ;
77
80
}
78
81
79
82
function updateSelection(params : SelectionParams ) {
@@ -88,7 +91,7 @@ function updateSelection(params: SelectionParams) {
88
91
89
92
const urlParams = getUrlParams ();
90
93
91
- // Include all relevant changes in the compile-time tab summary
94
+ // Include all relevant changes in the compile-time tab summary.
92
95
// We do not wrap it in computed, because it should be loaded only once, after
93
96
// the data is downloaded.
94
97
const compileSummary: Ref <SummaryGroup | null > = ref (null );
@@ -100,6 +103,14 @@ const selector = loadSelectorFromUrl(urlParams);
100
103
101
104
const initialTab: Tab = loadTabFromUrl (urlParams ) ?? Tab .CompileTime ;
102
105
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 );
103
114
104
115
function changeTab(newTab : Tab ) {
105
116
tab .value = newTab ;
@@ -130,10 +141,13 @@ loadCompareData(selector, loading);
130
141
:initial-tab =" initialTab"
131
142
:compile-time-summary =" compileSummary"
132
143
/>
133
- <template v-if =" tab === Tab .CompileTime " >
144
+ <template v-if =" activeTab === Tab .CompileTime " >
134
145
<CompileBenchmarksPage :data =" data" :selector =" selector" />
135
146
</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 >
137
151
</div >
138
152
</div >
139
153
<br />
0 commit comments