Skip to content

Commit e5f54ff

Browse files
committed
Make rustc-perf example Cargo commands more bulletproof
1 parent 5d807e5 commit e5f54ff

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

site/frontend/src/pages/compare/compile/table/shortcuts/binary-size-shortcut.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {CompileTestCase} from "../../common";
88
import {ArtifactDescription} from "../../../types";
99
import Tooltip from "../../../tooltip.vue";
1010
import {normalizeProfile} from "./utils";
11+
import {cargo_collector_command} from "../../../../../utils/cargo";
1112
1213
const props = defineProps<{
1314
artifact: ArtifactDescription;
@@ -30,13 +31,12 @@ function normalizeBackend(backend: string): string {
3031
Command for analyzing binary size locally
3132
<Tooltip>
3233
Execute this command in a checkout of
33-
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>, after a
34-
`cargo build --release`, to compare binary section sizes. Add `--symbols`
35-
to include a diff of symbol sizes.
34+
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>. Add
35+
`--symbols` to include a diff of symbol sizes.
3636
</Tooltip>
3737
</div>
3838

39-
<pre><code>cargo run --release --bin collector \
39+
<pre><code>{{ cargo_collector_command() }} \
4040
binary_stats compile \
4141
+{{ props.baseArtifact.commit }} \
4242
--rustc2 +{{ props.artifact.commit }} \

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import {CompileTestCase} from "../../common";
77
import {computed} from "vue";
88
import {normalizeProfile} from "./utils";
9+
import {cargo_collector_command} from "../../../../../utils/cargo";
910
1011
const props = defineProps<{
1112
commit: string;
@@ -36,7 +37,7 @@ function normalizeScenario(scenario: string): string {
3637
</script>
3738

3839
<template>
39-
<pre><code>cargo run --release --bin collector \
40+
<pre><code>{{ cargo_collector_command() }} \
4041
profile_local cachegrind \
4142
+{{ firstCommit }} \<template v-if="props.baselineCommit !== undefined">
4243
--rustc2 +{{ props.commit }} \</template>

site/frontend/src/pages/compare/compile/table/shortcuts/profile-shortcut.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const profileBaselineCommit = computed(() => {
4949
Command for profiling locally
5050
<Tooltip>
5151
Execute this command in a checkout of
52-
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>, after a
53-
`cargo build --release`, to generate a Cachegrind profile.
52+
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a> to
53+
generate a Cachegrind profile.
5454
</Tooltip>
5555
</div>
5656

site/frontend/src/pages/detailed-query/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
chromeProfileUrl,
33
processedSelfProfileRelativeUrl,
44
} from "../../self-profile";
5+
import {cargo_collector_command} from "../../utils/cargo";
56

67
export interface Selector {
78
commit: string;
@@ -198,23 +199,23 @@ export function createDownloadLinksData(selector: Selector | null): {
198199

199200
const localCommands = {
200201
base: state.base_commit
201-
? `cargo run --release --bin collector profile_local cachegrind
202+
? `${cargo_collector_command()} profile_local cachegrind
202203
+${state.base_commit} --exact-match ${benchName(
203204
state.benchmark
204205
)} --profiles
205206
${profile(state.benchmark)} --scenarios ${scenarioFilter(
206207
state.scenario
207208
)}`
208209
: "",
209-
new: `cargo run --release --bin collector profile_local cachegrind
210+
new: `${cargo_collector_command()} profile_local cachegrind
210211
+${state.commit} --exact-match ${benchName(
211212
state.benchmark
212213
)} --profiles
213214
${profile(state.benchmark)} --scenarios ${scenarioFilter(
214215
state.scenario
215216
)}`,
216217
diff: state.base_commit
217-
? `cargo run --release --bin collector profile_local cachegrind
218+
? `${cargo_collector_command()} profile_local cachegrind
218219
+${state.base_commit} --rustc2 +${
219220
state.commit
220221
} --exact-match ${benchName(state.benchmark)} --profiles

site/frontend/src/utils/cargo.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Return a Cargo command that builds rustc-perf properly and then executes
3+
* the collector.
4+
* The returned command is meant to be followed by a `collector` command and its
5+
* arguments.
6+
*/
7+
export function cargo_collector_command(): string {
8+
return "cargo build --release -p collector && ./target/release/collector";
9+
}

0 commit comments

Comments
 (0)