Skip to content

Commit

Permalink
Store self compare backend checkbox in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Nov 17, 2024
1 parent cd5b340 commit 9b2d3fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions site/frontend/src/pages/compare/compile/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type CompileBenchmarkFilter = {
binary: boolean;
library: boolean;
};
selfCompareBackend: boolean;
} & BenchmarkFilter;

export const defaultCompileFilter: CompileBenchmarkFilter = {
Expand Down Expand Up @@ -57,6 +58,7 @@ export const defaultCompileFilter: CompileBenchmarkFilter = {
binary: true,
library: true,
},
selfCompareBackend: false,
};

export type Profile = "check" | "debug" | "opt" | "doc";
Expand Down
25 changes: 23 additions & 2 deletions site/frontend/src/pages/compare/compile/compile-page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ function loadFilterFromUrl(
defaultFilter.artifact.library
),
},
selfCompareBackend: getBoolOrDefault(
urlParams,
"selfCompareBackend",
defaultFilter.selfCompareBackend
),
};
}
Expand Down Expand Up @@ -173,6 +178,11 @@ function storeFilterToUrl(
filter.artifact.library,
defaultFilter.artifact.library
);
storeOrReset(
"selfCompareBackend",
filter.selfCompareBackend,
defaultFilter.selfCompareBackend
);
changeUrl(urlParams);
}
Expand All @@ -183,6 +193,10 @@ function updateFilter(newFilter: CompileBenchmarkFilter) {
refreshQuickLinks();
}
function updateSelfCompareBackend(value: boolean) {
updateFilter({...filter.value, selfCompareBackend: value});
}
/**
* When the filter changes, the URL is updated.
* After that happens, we want to re-render the quick links component, because
Expand All @@ -199,7 +213,9 @@ const quickLinksKey = ref(0);
const filter = ref(loadFilterFromUrl(urlParams, defaultCompileFilter));
// Should we use the backend as the source of before/after data?
const selfCompareBackend = ref(false);
const selfCompareBackend = computed(
() => comparesIdenticalCommits.value && filter.value.selfCompareBackend
);
function exportData() {
exportToMarkdown(comparisons.value, filter.value.showRawData);
Expand Down Expand Up @@ -240,7 +256,12 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
:metrics="benchmarkInfo.compile_metrics"
/>
<div v-if="comparesIdenticalCommits">
Self-compare backend: <input type="checkbox" v-model="selfCompareBackend" />
Self-compare backend:
<input
type="checkbox"
:checked="selfCompareBackend"
@change="(e) => updateSelfCompareBackend(e.target.checked)"
/>
</div>
<Filters
:defaultFilter="defaultCompileFilter"
Expand Down

0 comments on commit 9b2d3fb

Please sign in to comment.