@@ -14,6 +14,7 @@ import {
14
14
computeCompileComparisonsWithNonRelevant ,
15
15
createCompileBenchmarkMap ,
16
16
defaultCompileFilter ,
17
+ transformDataForBackendComparison ,
17
18
} from " ./common" ;
18
19
import {BenchmarkInfo } from " ../../../api" ;
19
20
import {importantCompileMetrics } from " ../metrics" ;
@@ -101,6 +102,11 @@ function loadFilterFromUrl(
101
102
defaultFilter .artifact .library
102
103
),
103
104
},
105
+ selfCompareBackend: getBoolOrDefault (
106
+ urlParams ,
107
+ " selfCompareBackend" ,
108
+ defaultFilter .selfCompareBackend
109
+ ),
104
110
};
105
111
}
106
112
@@ -172,6 +178,11 @@ function storeFilterToUrl(
172
178
filter .artifact .library ,
173
179
defaultFilter .artifact .library
174
180
);
181
+ storeOrReset (
182
+ " selfCompareBackend" ,
183
+ filter .selfCompareBackend ,
184
+ defaultFilter .selfCompareBackend
185
+ );
175
186
176
187
changeUrl (urlParams );
177
188
}
@@ -182,6 +193,13 @@ function updateFilter(newFilter: CompileBenchmarkFilter) {
182
193
refreshQuickLinks ();
183
194
}
184
195
196
+ // We pass the event target here, because Parcel cannot handle the `as`
197
+ // cast directly in the template.
198
+ function updateSelfCompareBackend(target : EventTarget ) {
199
+ const element = target as HTMLInputElement ;
200
+ updateFilter ({... filter .value , selfCompareBackend: element .checked });
201
+ }
202
+
185
203
/**
186
204
* When the filter changes, the URL is updated.
187
205
* After that happens, we want to re-render the quick links component, because
@@ -197,15 +215,36 @@ const urlParams = getUrlParams();
197
215
const quickLinksKey = ref (0 );
198
216
const filter = ref (loadFilterFromUrl (urlParams , defaultCompileFilter ));
199
217
218
+ // Should we use the backend as the source of before/after data?
219
+ const selfCompareBackend = computed (() => {
220
+ return canCompareBackends .value && filter .value .selfCompareBackend ;
221
+ });
222
+ const canCompareBackends = computed (() => {
223
+ const hasMultipleBackends =
224
+ new Set (props .data .compile_comparisons .map ((c ) => c .backend )).size > 1 ;
225
+ // Are we currently comparing the same commit in the before/after toolchains?
226
+ const comparesSameCommit = props .data .a .commit === props .data .b .commit ;
227
+ return hasMultipleBackends && comparesSameCommit ;
228
+ });
229
+
200
230
function exportData() {
201
231
exportToMarkdown (comparisons .value , filter .value .showRawData );
202
232
}
203
233
204
234
const benchmarkMap = createCompileBenchmarkMap (props .data );
235
+
236
+ const compileComparisons = computed (() => {
237
+ // If requested, artificially restructure the data to create a comparison between backends
238
+ if (selfCompareBackend .value ) {
239
+ return transformDataForBackendComparison (props .data .compile_comparisons );
240
+ } else {
241
+ return props .data .compile_comparisons ;
242
+ }
243
+ });
205
244
const allComparisons = computed (() =>
206
245
computeCompileComparisonsWithNonRelevant (
207
246
filter .value ,
208
- props . data . compile_comparisons ,
247
+ compileComparisons . value ,
209
248
benchmarkMap
210
249
)
211
250
);
@@ -222,6 +261,17 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
222
261
:selected-metric =" selector.stat"
223
262
:metrics =" benchmarkInfo.compile_metrics"
224
263
/>
264
+ <div
265
+ v-if =" canCompareBackends"
266
+ :title =" `Compare codegen backends for commit '${props.data.a.commit}'`"
267
+ >
268
+ Compare codegen backends for this commit:
269
+ <input
270
+ type =" checkbox"
271
+ :checked =" selfCompareBackend"
272
+ @change =" (e) => updateSelfCompareBackend(e.target)"
273
+ />
274
+ </div >
225
275
<Filters
226
276
:defaultFilter =" defaultCompileFilter"
227
277
:initialFilter =" filter"
@@ -230,12 +280,23 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
230
280
/>
231
281
<OverallSummary :summary =" filteredSummary" />
232
282
<Aggregations :cases =" comparisons" />
283
+ <div class =" warning" v-if =" selfCompareBackend" >
284
+ Note: comparing results of the baseline LLVM backend to the Cranelift
285
+ backend.
286
+ </div >
233
287
<Benchmarks
234
288
:data =" data"
235
289
:test-cases =" comparisons"
236
290
:all-test-cases =" allComparisons"
237
291
:filter =" filter"
238
292
:stat =" selector.stat"
239
293
:benchmark-map =" benchmarkMap"
294
+ :show-backend =" !selfCompareBackend"
240
295
></Benchmarks >
241
296
</template >
297
+ <style lang="scss" scoped>
298
+ .warning {
299
+ color : red ;
300
+ font-weight : bold ;
301
+ }
302
+ </style >
0 commit comments