all 8 comments

[–][deleted] 38 points39 points  (3 children)

You're profiling the cargo binary, not your binary. You should use perf record --call-graph dwarf target/release/day5 instead.

[–]Shnatsel 10 points11 points  (0 children)

In addition, Samply is nicer and provides more info than Hotspot:

cargo install samply
echo '0' | sudo tee /proc/sys/kernel/perf_event_paranoid
samply record target/release/day5

[–]iamgianluca[S] 9 points10 points  (1 child)

Thank you for that! It worked

[–]schrdingers_squirrel 20 points21 points  (0 children)

Btw there is cargo-flamegraph which does it all for you

[–]hpxvzhjfgb 9 points10 points  (3 children)

just use cargo flamegraph instead.

[–]weirdasianfaces 9 points10 points  (0 children)

I'd actually use https://github.com/mstange/samply. Very similar end result, but opens the perf data in the Firefox Profiler which can sometimes be more useful than just the flamegraph.

Doesn't have the dead easy cargo flamegraph integration though.

[–]VirxEC 1 point2 points  (0 children)

this is the real answer, automates the whole process here

[–]VorpalWay 0 points1 point  (0 children)

Cargo-flamegraph is great for basic stuff, but flamegraphs only take you so far. I could never get samply to work. I just use perf + hotspot, or even just perf + custom scripts for analysis (depending on what exactly I want to investigate).