@@ -28,7 +28,7 @@ of events, though, like cache misses and so forth.
28
28
The basic ` perf ` command is this:
29
29
30
30
``` bash
31
- > perf record -F99 --call-graph dwarf XXX
31
+ perf record -F99 --call-graph dwarf XXX
32
32
```
33
33
34
34
The ` -F99 ` tells perf to sample at 99 Hz, which avoids generating too
@@ -39,7 +39,7 @@ information from debuginfo, which is accurate. The `XXX` is the
39
39
command you want to profile. So, for example, you might do:
40
40
41
41
``` bash
42
- > perf record -F99 --call-graph dwarf cargo +< toolchain> rustc
42
+ perf record -F99 --call-graph dwarf cargo +< toolchain> rustc
43
43
```
44
44
45
45
to run ` cargo ` -- here ` <toolchain> ` should be the name of the toolchain
@@ -59,7 +59,7 @@ do that, the first step is to clone
59
59
[ the rustc-perf repository] [ rustc-perf-gh ] :
60
60
61
61
``` bash
62
- > git clone https://github.com/rust-lang-nursery/rustc-perf
62
+ git clone https://github.com/rust-lang-nursery/rustc-perf
63
63
```
64
64
65
65
[ rustc-perf-gh ] : https://github.com/rust-lang-nursery/rustc-perf
@@ -75,13 +75,13 @@ do profiling for you! You can find
75
75
For example, to measure the clap-rs test, you might do:
76
76
77
77
``` bash
78
- > ./target/release/collector
79
- --output-repo /path/to/place/output
80
- profile perf-record
81
- --rustc /path/to/rustc/executable/from/your/build/directory
82
- --cargo ` which cargo`
83
- --filter clap-rs
84
- --builds Check
78
+ ./target/release/collector \
79
+ --output-repo /path/to/place/output \
80
+ profile perf-record \
81
+ --rustc /path/to/rustc/executable/from/your/build/directory \
82
+ --cargo ` which cargo` \
83
+ --filter clap-rs \
84
+ --builds Check \
85
85
```
86
86
87
87
You can also use that same command to use cachegrind or other profiling tools.
@@ -97,7 +97,7 @@ example:
97
97
[ dir ] : https://github.com/rust-lang-nursery/rustc-perf/tree/master/collector/benchmarks
98
98
99
99
``` bash
100
- > cd collector/benchmarks/clap-rs
100
+ cd collector/benchmarks/clap-rs
101
101
```
102
102
103
103
In this case, let's say we want to profile the ` cargo check `
@@ -106,8 +106,8 @@ build the dependencies:
106
106
107
107
``` bash
108
108
# Setup: first clean out any old results and build the dependencies:
109
- > cargo +< toolchain> clean
110
- > CARGO_INCREMENTAL=0 cargo +< toolchain> check
109
+ cargo +< toolchain> clean
110
+ CARGO_INCREMENTAL=0 cargo +< toolchain> check
111
111
```
112
112
113
113
(Again, ` <toolchain> ` should be replaced with the name of the
@@ -118,8 +118,8 @@ running cargo check. I tend to use `cargo rustc` for this, since it
118
118
also allows me to add explicit flags, which we'll do later on.
119
119
120
120
``` bash
121
- > touch src/lib.rs
122
- > CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib
121
+ touch src/lib.rs
122
+ CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib
123
123
```
124
124
125
125
Note that final command: it's a doozy! It uses the ` cargo rustc `
@@ -130,7 +130,7 @@ the `--profile check` and `--lib` options specify that we are doing a
130
130
At this point, we can use ` perf ` tooling to analyze the results. For example:
131
131
132
132
``` bash
133
- > perf report
133
+ perf report
134
134
```
135
135
136
136
will open up an interactive TUI program. In simple cases, that can be
@@ -149,8 +149,8 @@ If you want to profile an NLL run, you can just pass extra options to
149
149
the ` cargo rustc ` command, like so:
150
150
151
151
``` bash
152
- > touch src/lib.rs
153
- > CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib -- -Zborrowck=mir
152
+ touch src/lib.rs
153
+ CARGO_INCREMENTAL=0 perf record -F99 --call-graph dwarf cargo rustc --profile check --lib -- -Zborrowck=mir
154
154
```
155
155
156
156
[ pf ] : https://github.com/nikomatsakis/perf-focus
@@ -180,7 +180,7 @@ would analyze NLL performance.
180
180
You can install perf-focus using ` cargo install ` :
181
181
182
182
``` bash
183
- > cargo install perf-focus
183
+ cargo install perf-focus
184
184
```
185
185
186
186
### Example: How much time is spent in MIR borrowck?
@@ -191,7 +191,7 @@ function of the MIR borrowck is called `do_mir_borrowck`, so we can do
191
191
this command:
192
192
193
193
``` bash
194
- > perf focus ' {do_mir_borrowck}'
194
+ $ perf focus ' {do_mir_borrowck}'
195
195
Matcher : {do_mir_borrowck}
196
196
Matches : 228
197
197
Not Matches: 542
@@ -216,7 +216,7 @@ samples where `do_mir_borrowck` was on the stack: in this case, 29%.
216
216
by doing:
217
217
218
218
``` bash
219
- > perf script | c++filt | perf focus --from-stdin ...
219
+ perf script | c++filt | perf focus --from-stdin ...
220
220
```
221
221
222
222
This will pipe the output from ` perf script ` through ` c++filt ` and
@@ -232,7 +232,7 @@ Perhaps we'd like to know how much time MIR borrowck spends in the
232
232
trait checker. We can ask this using a more complex regex:
233
233
234
234
``` bash
235
- > perf focus ' {do_mir_borrowck}..{^rustc::traits}'
235
+ $ perf focus ' {do_mir_borrowck}..{^rustc::traits}'
236
236
Matcher : {do_mir_borrowck},..{^rustc::traits}
237
237
Matches : 12
238
238
Not Matches: 1311
@@ -260,7 +260,7 @@ usually also want to give `--tree-min-percent` or
260
260
` --tree-max-depth ` . The result looks like this:
261
261
262
262
``` bash
263
- > perf focus ' {do_mir_borrowck}' --tree-callees --tree-min-percent 3
263
+ $ perf focus ' {do_mir_borrowck}' --tree-callees --tree-min-percent 3
264
264
Matcher : {do_mir_borrowck}
265
265
Matches : 577
266
266
Not Matches: 746
@@ -311,7 +311,7 @@ could get our percentages relative to the borrowck itself
311
311
like so:
312
312
313
313
``` bash
314
- > perf focus ' {do_mir_borrowck}' --tree-callees --relative --tree-max-depth 1 --tree-min-percent 5
314
+ $ perf focus ' {do_mir_borrowck}' --tree-callees --relative --tree-max-depth 1 --tree-min-percent 5
315
315
Matcher : {do_mir_borrowck}
316
316
Matches : 577
317
317
Not Matches: 746
0 commit comments