Skip to content

Commit 8d07e53

Browse files
committed
Add drop-down selection of Cachegrind profiles
1 parent b0a8625 commit 8d07e53

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

site/frontend/src/components/cachegrind-cmd.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import {computed} from "vue";
55
const props = defineProps<{
66
commit: string;
77
testCase: CompileTestCase;
8-
baseline_commit?: string;
8+
baselineCommit?: string;
99
}>();
1010
1111
const firstCommit = computed(() => {
12-
if (props.baseline_commit !== undefined) {
13-
return props.baseline_commit;
12+
if (props.baselineCommit !== undefined) {
13+
return props.baselineCommit;
1414
} else {
1515
return props.commit;
1616
}
@@ -44,7 +44,7 @@ function normalizeScenario(scenario: string): string {
4444

4545
<template>
4646
<pre><code>cargo run --bin collector --release profile_local cachegrind \
47-
+{{ firstCommit }} \<template v-if="props.baseline_commit !== undefined">
47+
+{{ firstCommit }} \<template v-if="props.baselineCommit !== undefined">
4848
--rustc2 +{{ props.commit }} \</template>
4949
--include {{ testCase.benchmark }} \
5050
--profiles {{ normalizeProfile(testCase.profile) }} \

site/frontend/src/pages/compare/compile/table/benchmark-detail.vue

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,31 @@ const cargoProfile = computed((): CargoProfileMetadata => {
179179
const chartElement: Ref<HTMLElement | null> = ref(null);
180180
const graphRange = computed(() => getGraphRange(props.artifact));
181181
182+
enum ProfileCommand {
183+
Before = "before",
184+
After = "after",
185+
Diff = "diff",
186+
}
187+
188+
const profileCommand: Ref<ProfileCommand> = ref(ProfileCommand.Diff);
189+
const profileCommit = computed(() => {
190+
if (profileCommand.value === ProfileCommand.Before) {
191+
return props.baseArtifact.commit;
192+
}
193+
return props.artifact.commit;
194+
});
195+
const profileBaselineCommit = computed(() => {
196+
if (profileCommand.value === ProfileCommand.Diff) {
197+
return props.baseArtifact.commit;
198+
}
199+
return undefined;
200+
});
201+
202+
function changeProfileCommand(event: Event) {
203+
const target = event.target as HTMLSelectElement;
204+
profileCommand.value = target.value as ProfileCommand;
205+
}
206+
182207
onMounted(() => renderGraph());
183208
</script>
184209

@@ -288,12 +313,34 @@ onMounted(() => renderGraph());
288313
Local profiling command<Tooltip>
289314
Execute this command in a checkout of
290315
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>
291-
to generate a Cachegrind diff between the two artifacts.
316+
to generate a Cachegrind profile.
292317
</Tooltip>
293318
</div>
319+
320+
<select @change="changeProfileCommand">
321+
<option
322+
:value="ProfileCommand.Diff"
323+
:selected="profileCommand === ProfileCommand.Diff"
324+
>
325+
Diff
326+
</option>
327+
<option
328+
:value="ProfileCommand.Before"
329+
:selected="profileCommand === ProfileCommand.Before"
330+
>
331+
Baseline commit
332+
</option>
333+
<option
334+
:value="ProfileCommand.After"
335+
:selected="profileCommand === ProfileCommand.After"
336+
>
337+
Benchmarked commit
338+
</option>
339+
</select>
340+
294341
<CachegrindCmd
295-
:commit="artifact.commit"
296-
:baseline_commit="baseArtifact.commit"
342+
:commit="profileCommit"
343+
:baseline-commit="profileBaselineCommit"
297344
:test-case="testCase"
298345
/>
299346
</div>

0 commit comments

Comments
 (0)