Skip to content

Commit cea342e

Browse files
committed
Add a command shortcut for analyzing binary size to benchmark detail
1 parent 82b3ad3 commit cea342e

File tree

4 files changed

+89
-17
lines changed

4 files changed

+89
-17
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import CompileSectionsChart from "./sections-chart.vue";
2424
import PerfettoLink from "../../../../components/perfetto-link.vue";
2525
import ProfileShortcut from "./shortcuts/profile-shortcut.vue";
26+
import BinarySizeShortcut from "./shortcuts/binary-size-shortcut.vue";
2627
2728
const props = defineProps<{
2829
testCase: CompileTestCase;
@@ -32,6 +33,8 @@ const props = defineProps<{
3233
benchmarkMap: CompileBenchmarkMap;
3334
}>();
3435
36+
const BINARY_SIZE_METRIC: string = "size:linked_artifact";
37+
3538
type GraphRange = {
3639
start: string;
3740
end: string;
@@ -348,17 +351,17 @@ onMounted(() => {
348351
<PerfettoLink
349352
:artifact="props.baseArtifact"
350353
:test-case="props.testCase"
351-
>query trace</PerfettoLink
352-
>
354+
>query trace
355+
</PerfettoLink>
353356
</li>
354357
<li>
355358
After:
356359
<a :href="detailedQueryLink(props.artifact)" target="_blank"
357360
>self-profile</a
358361
>,
359362
<PerfettoLink :artifact="props.artifact" :test-case="props.testCase"
360-
>query trace</PerfettoLink
361-
>
363+
>query trace
364+
</PerfettoLink>
362365
</li>
363366
<li>
364367
<a
@@ -431,7 +434,16 @@ onMounted(() => {
431434
</div>
432435
</div>
433436
<div class="shortcut">
437+
<template v-if="props.metric === BINARY_SIZE_METRIC">
438+
<BinarySizeShortcut
439+
v-if="testCase.profile === 'debug' || testCase.profile === 'opt'"
440+
:artifact="props.artifact"
441+
:base-artifact="props.baseArtifact"
442+
:test-case="props.testCase"
443+
/>
444+
</template>
434445
<ProfileShortcut
446+
v-else
435447
:artifact="props.artifact"
436448
:base-artifact="props.baseArtifact"
437449
:test-case="props.testCase"
@@ -455,9 +467,11 @@ onMounted(() => {
455467
flex-wrap: nowrap;
456468
}
457469
}
470+
458471
.graphs {
459472
margin-top: 15px;
460473
}
474+
461475
.rows {
462476
display: flex;
463477
flex-direction: column;
@@ -467,6 +481,7 @@ onMounted(() => {
467481
align-items: center;
468482
}
469483
}
484+
470485
.shortcut {
471486
margin-top: 15px;
472487
text-align: left;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<script setup lang="ts">
2+
import {CompileTestCase} from "../../common";
3+
import {ArtifactDescription} from "../../../types";
4+
import Tooltip from "../../../tooltip.vue";
5+
import {normalizeProfile} from "./utils";
6+
7+
const props = defineProps<{
8+
artifact: ArtifactDescription;
9+
baseArtifact: ArtifactDescription;
10+
testCase: CompileTestCase;
11+
}>();
12+
13+
function normalizeBackend(backend: string): string {
14+
if (backend === "llvm") {
15+
return "Llvm";
16+
} else if (backend == "cranelift") {
17+
return "Cranelift";
18+
}
19+
return "<invalid backend>";
20+
}
21+
</script>
22+
23+
<template>
24+
<div class="title">
25+
Command for analyzing binary size locally
26+
<Tooltip>
27+
Execute this command in a checkout of
28+
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>, after a
29+
`cargo build --release`, to compare binary sizes.
30+
</Tooltip>
31+
</div>
32+
33+
<pre><code>./target/release/collector binary_stats \
34+
+{{ props.baseArtifact.commit }} \
35+
--rustc2 +{{ props.artifact.commit }} \
36+
--include {{ testCase.benchmark }} \
37+
--profile {{ normalizeProfile(testCase.profile) }} \
38+
--backend {{ normalizeBackend(testCase.backend) }}</code></pre>
39+
</template>
40+
41+
<style scoped lang="scss">
42+
.title {
43+
font-weight: bold;
44+
}
45+
46+
pre {
47+
background-color: #eeeeee;
48+
}
49+
50+
code {
51+
user-select: all;
52+
}
53+
</style>

site/frontend/src/pages/compare/compile/table/shortcuts/cachegrind-cmd.vue

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
/**
33
* This component displays a rustc-perf command for profiling a compile benchmark with Cachegrind.
44
* */
5-
import {CompileTestCase, Profile} from "../../common";
5+
import {CompileTestCase} from "../../common";
66
import {computed} from "vue";
7+
import {normalizeProfile} from "./utils";
78
89
const props = defineProps<{
910
commit: string;
@@ -19,18 +20,6 @@ const firstCommit = computed(() => {
1920
}
2021
});
2122
22-
function normalizeProfile(profile: Profile): string {
23-
if (profile === "opt") {
24-
return "Opt";
25-
} else if (profile === "debug") {
26-
return "Debug";
27-
} else if (profile === "check") {
28-
return "Check";
29-
} else if (profile === "doc") {
30-
return "Doc";
31-
}
32-
return "<invalid profile>";
33-
}
3423
function normalizeScenario(scenario: string): string {
3524
if (scenario === "full") {
3625
return "Full";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Profile} from "../../common";
2+
3+
// Normalize profile from a test case to a CLI value for collector.
4+
export function normalizeProfile(profile: Profile): string {
5+
if (profile === "opt") {
6+
return "Opt";
7+
} else if (profile === "debug") {
8+
return "Debug";
9+
} else if (profile === "check") {
10+
return "Check";
11+
} else if (profile === "doc") {
12+
return "Doc";
13+
}
14+
return "<invalid profile>";
15+
}

0 commit comments

Comments
 (0)