5 The `-Zself-profile` compiler flag enables rustc's internal profiler.
6 When enabled, the compiler will output three binary files in the specified directory (or the current working directory if no directory is specified).
7 These files can be analyzed by using the tools in the [`measureme`] repository.
9 To control the data recorded in the trace files, use the `-Zself-profile-events` flag.
13 First, run a compilation session and provide the `-Zself-profile` flag:
16 $ rustc --crate-name foo -Zself-profile
19 This will generate three files in the working directory such as:
22 - `foo-1234.string_data`
23 - `foo-1234.string_index`
25 Where `foo` is the name of the crate and `1234` is the process id of the rustc process.
27 To get a summary of where the compiler is spending its time:
30 $ ../measureme/target/release/summarize summarize foo-1234
33 To generate a flamegraph of the same data:
36 $ ../measureme/target/release/inferno foo-1234
39 To dump the event data in a Chromium-profiler compatible format:
42 $ ../measureme/target/release/crox foo-1234
45 For more information, consult the [`measureme`] documentation.
47 [`measureme`]: https://github.com/rust-lang/measureme.git