Tome of Finite Knowledge

Home

❯

Programming

❯

Python

❯

Call graph profiling

Call-graph profiling

Jun 14, 20261 min read

  • python

python

See also

  • https://stackoverflow.com/a/23164271
  • https://graphviz.org/doc/info/command.html

Given a Python program main.py:

  1. python -m cProfile -o main.py.profile main.py
    • If you need to pass args to main.py, do so after its appearance in this command
  2. gprof2dot -f pstats main.py.profile -o main.py.dot
  3. dot -Tpng main.py.dot

Open main.py.png and viola!


Graph View

Created with Quartz v4.5.2 © 2026

  • GitHub
  • Discord Community