Documentation for v0.4.x
This applies to pycallgraph v0.4.x. To see other versions go here.
Requirements
You will need Graphviz installed and in your path. To see if it's installed and in your path, the command "dot" should work from the command line.
Installation
pycallgraph works with Linux, Windows and Mac OS X. There are two ways of installing pycallgraph:
If you have setuptools installed, simply run the following:
easy_install pycallgraph
Or download the package shown below, extract it, hop into the directory and run:
python setup.py install
Download
Source Code
Windows
Debian
Jan Michael Alonzo is maintaining a Debian package at (currently version 0.3.0):
FreeBSD
Li-Wen Hsu is maintaining a FreeBSD package on FreshPorts:
OpenSUSE
OpenSUSE has a python-pycallgraph package:
Subversion
svn co svn://slowchop.com/pycallgraph/trunk/
Older Releases
Documentation
Usage
Command Line Interface
As of version 0.4.0, there is a command line interface to pycallgraph called pycallgraph-dot.py. It is installed in your Python scripts path as part of setup.
A simple example is:
pycallgraph-dot.py --image-format=png mypythonapp.py graph.png
For more options run:
pycallgraph-dot.py --help
Module Interface
You may import pycallgraph as a module and run the trace graph within your application.
Just before your first line of code you want to graph, put in the following code:
import pycallgraph pycallgraph.start_trace()
To stop the trace and generate the graph, put in the following code (usually at the end of your program):
pycallgraph.make_dot_graph('test.png')
The default is to output in png with with the dot tool. You can change them by specifying arguments:
pycallgraph.make_dot_graph('test.jpg', format='jpg', tool='neato')