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/.
Perf is a tool that acts like a stopwatch for your computer's processor, showing exactly which parts of your code are slowing things down. You use it after building your Rust program to find performance bottlenecks without needing to change your code. Think of it as a heat map that highlights the hottest, most active areas of your application so you know where to focus your optimization efforts.