@@ -28,7 +28,7 @@ of events, though, like cache misses and so forth.
2828The basic ` perf ` command is this:
2929
3030``` bash
31- > perf record -F99 --call-graph dwarf XXX
31+ perf record -F99 --call-graph dwarf XXX
3232```
3333
3434The ` -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
3939command you want to profile. So, for example, you might do:
4040
4141``` bash
42- > perf record -F99 --call-graph dwarf cargo +< toolchain> rustc
42+ perf record -F99 --call-graph dwarf cargo +< toolchain> rustc
4343```
4444
4545to run ` cargo ` -- here ` <toolchain> ` should be the name of the toolchain
@@ -59,7 +59,7 @@ do that, the first step is to clone
5959[ the rustc-perf repository] [ rustc-perf-gh ] :
6060
6161``` bash
62- > git clone https://github.com/rust-lang-nursery/rustc-perf
62+ git clone https://github.com/rust-lang-nursery/rustc-perf
6363```
6464
6565[ rustc-perf-gh ] : https://github.com/rust-lang-nursery/rustc-perf
@@ -75,13 +75,13 @@ do profiling for you! You can find
7575For example, to measure the clap-rs test, you might do:
7676
7777``` 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 \
8585```
8686
8787You can also use that same command to use cachegrind or other profiling tools.
@@ -97,7 +97,7 @@ example:
9797[ dir ] : https://github.com/rust-lang-nursery/rustc-perf/tree/master/collector/benchmarks
9898
9999``` bash
100- > cd collector/benchmarks/clap-rs
100+ cd collector/benchmarks/clap-rs
101101```
102102
103103In this case, let's say we want to profile the ` cargo check `
@@ -106,8 +106,8 @@ build the dependencies:
106106
107107``` bash
108108# 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
111111```
112112
113113(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
118118also allows me to add explicit flags, which we'll do later on.
119119
120120``` 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
123123```
124124
125125Note 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
130130At this point, we can use ` perf ` tooling to analyze the results. For example:
131131
132132``` bash
133- > perf report
133+ perf report
134134```
135135
136136will 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
149149the ` cargo rustc ` command, like so:
150150
151151``` 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
154154```
155155
156156[ pf ] : https://github.com/nikomatsakis/perf-focus
@@ -180,7 +180,7 @@ would analyze NLL performance.
180180You can install perf-focus using ` cargo install ` :
181181
182182``` bash
183- > cargo install perf-focus
183+ cargo install perf-focus
184184```
185185
186186### 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
191191this command:
192192
193193``` bash
194- > perf focus ' {do_mir_borrowck}'
194+ $ perf focus ' {do_mir_borrowck}'
195195Matcher : {do_mir_borrowck}
196196Matches : 228
197197Not Matches: 542
@@ -216,7 +216,7 @@ samples where `do_mir_borrowck` was on the stack: in this case, 29%.
216216 by doing:
217217
218218``` bash
219- > perf script | c++filt | perf focus --from-stdin ...
219+ perf script | c++filt | perf focus --from-stdin ...
220220```
221221
222222This 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
232232trait checker. We can ask this using a more complex regex:
233233
234234``` bash
235- > perf focus ' {do_mir_borrowck}..{^rustc::traits}'
235+ $ perf focus ' {do_mir_borrowck}..{^rustc::traits}'
236236Matcher : {do_mir_borrowck},..{^rustc::traits}
237237Matches : 12
238238Not Matches: 1311
@@ -260,7 +260,7 @@ usually also want to give `--tree-min-percent` or
260260` --tree-max-depth ` . The result looks like this:
261261
262262``` 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
264264Matcher : {do_mir_borrowck}
265265Matches : 577
266266Not Matches: 746
@@ -311,7 +311,7 @@ could get our percentages relative to the borrowck itself
311311like so:
312312
313313``` 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
315315Matcher : {do_mir_borrowck}
316316Matches : 577
317317Not Matches: 746
0 commit comments