@@ -14,6 +14,7 @@ import {
1414 computeCompileComparisonsWithNonRelevant ,
1515 createCompileBenchmarkMap ,
1616 defaultCompileFilter ,
17+ transformDataForBackendComparison ,
1718} from " ./common" ;
1819import {BenchmarkInfo } from " ../../../api" ;
1920import {importantCompileMetrics } from " ../metrics" ;
@@ -101,6 +102,11 @@ function loadFilterFromUrl(
101102 defaultFilter .artifact .library
102103 ),
103104 },
105+ selfCompareBackend: getBoolOrDefault (
106+ urlParams ,
107+ " selfCompareBackend" ,
108+ defaultFilter .selfCompareBackend
109+ ),
104110 };
105111}
106112
@@ -172,6 +178,11 @@ function storeFilterToUrl(
172178 filter .artifact .library ,
173179 defaultFilter .artifact .library
174180 );
181+ storeOrReset (
182+ " selfCompareBackend" ,
183+ filter .selfCompareBackend ,
184+ defaultFilter .selfCompareBackend
185+ );
175186
176187 changeUrl (urlParams );
177188}
@@ -182,6 +193,13 @@ function updateFilter(newFilter: CompileBenchmarkFilter) {
182193 refreshQuickLinks ();
183194}
184195
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+
185203/**
186204 * When the filter changes, the URL is updated.
187205 * After that happens, we want to re-render the quick links component, because
@@ -197,15 +215,36 @@ const urlParams = getUrlParams();
197215const quickLinksKey = ref (0 );
198216const filter = ref (loadFilterFromUrl (urlParams , defaultCompileFilter ));
199217
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+
200230function exportData() {
201231 exportToMarkdown (comparisons .value , filter .value .showRawData );
202232}
203233
204234const 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+ });
205244const allComparisons = computed (() =>
206245 computeCompileComparisonsWithNonRelevant (
207246 filter .value ,
208- props . data . compile_comparisons ,
247+ compileComparisons . value ,
209248 benchmarkMap
210249 )
211250);
@@ -222,6 +261,17 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
222261 :selected-metric =" selector.stat"
223262 :metrics =" benchmarkInfo.compile_metrics"
224263 />
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 >
225275 <Filters
226276 :defaultFilter =" defaultCompileFilter"
227277 :initialFilter =" filter"
@@ -230,12 +280,23 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
230280 />
231281 <OverallSummary :summary =" filteredSummary" />
232282 <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 >
233287 <Benchmarks
234288 :data =" data"
235289 :test-cases =" comparisons"
236290 :all-test-cases =" allComparisons"
237291 :filter =" filter"
238292 :stat =" selector.stat"
239293 :benchmark-map =" benchmarkMap"
294+ :show-backend =" !selfCompareBackend"
240295 ></Benchmarks >
241296</template >
297+ <style lang="scss" scoped>
298+ .warning {
299+ color : red ;
300+ font-weight : bold ;
301+ }
302+ </style >
0 commit comments