How to use perf with Rust

Compile your Rust project in release mode and run perf record on the resulting binary to generate a performance report.

Use perf on a Rust binary by compiling it in release mode and running perf record with the binary path.

cargo build --release
perf record -g ./target/release/your_binary_name
perf report

Replace your_binary_name with the actual name of your compiled executable found in target/release/.