pycallgraph 0.10 released

by Jeremy Jones

The 0.10 release for a project called "pycallgraph" just popped up on the Cheeseshop. This library is supposed to allow you to create graphviz diagrams based on your application's call tree. This sounded pretty interesting, so I decided to install it and see how well it worked.

I did an `easy_install` of the pycallgraph package and followed the usage directions on the pycallgraph main page. I have a simple little "main" module whose contents I've listed below. Basically, main calls mod1 which imports and calls mod2 which imports and calls mod3. Here is the code for `main.py`:

import mod1
import pycallgraph
pycallgraph.start_trace()
print mod1.mod1("Some Text String"), "\n"
pycallgraph.make_graph("callgraph.png")


The pycallgraph output was a little less than desirable:
callgraph.png

I thought that pycallgraph was confusing itself and not filtering its own activities, so I took a stroll through the source code to see if there was a "filter" option. That's when I noticed a `stop_trace()` function. When I changed my original script to look like this:

import mod1
import pycallgraph
pycallgraph.start_trace()
print mod1.mod1("Some Text String"), "\n"
pycallgraph.stop_trace() ##HERE'S THE stop_trace() CALL##
pycallgraph.make_graph("callgraph_clean.png")

here is the output that was created:
callgraph_clean.png

I can see this utility coming in handy.

1 Comments

Ivaylo Iltchev
2007-02-17 15:08:41
make_graph is deprecated, use make_dot_graph, make_dot_graph will stop trace also.
The End of example:
pycallgraph.stop_trace() ##HERE'S THE stop_trace() CALL##
pycallgraph.make_graph("callgraph_clean.png")
Become:

pycallgraph.make_dot_graph("callgraph_clean.png")