TIL: Running `cargo-flamegraph` With Tauri Apps

A Tauri app is just a Rust-compiled binary. But because the Tauri workflow also involves some frontend development you normally develop your app using something like:

pnpm tauri dev

So when I had to profile my app, it wasn’t immediately obvious how to invoke flamegraph, but it’s really simple:

cargo install flamegraph
pnpm tauri build # use --debug if you want to profile your debug build

flamegraph --root -- /Users/samrat/code/myapp/src-tauri/target/release/myapp

The flamegraph.svg file will be produced once you close your app.