Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klingtnet/02ef8de9e8476d6d34496d3db52602ce to your computer and use it in GitHub Desktop.
Save klingtnet/02ef8de9e8476d6d34496d3db52602ce to your computer and use it in GitHub Desktop.
How to make beautiful call graphs for Rust

I found the instructions in this reddit comment by the user fn_rust. Dependencies:

The instructions are illustrated on the rb crate:

  1. Build a binary with debug symbols (no --release flag was given): cargo build --example saw
  2. Run it with valgrind: valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes --simulate-cache=yes ./target/debug/examples/saw
  3. Convert the graph into a png: gprof2dot --format=callgrind callgrind.out.9815 | dot -o callgrind-graph.png -Tpng
  4. Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment