pycallgraph
Jun 10th, 2007 by antics
I saw pycallgraph on freshmeat today so spent a couple minutes playing with it. Initial impression is good and I’m looking forward to stretching its legs out soon. I through together a quick python script to see what pycallgraph is all about. Like most things in python is incredibily easy to use - with a couple lines of code you can add this into existing projects as well as new ones.

Here is the source for my test app:
#!/usr/bin/python
import pycallgraph
def aplusb(a,b):
if a == 7:
a = seven()
return a b
def aminusb(a,b):
return a - b
def printTest(input):
print 'Input is ' input
def seven():
return 7
#################
pycallgraph.start_trace()
print 'starting script'
list = []
list.append( aplusb(7,4) )
print '7 - 4 = ' str( aminusb(seven(),4) )
printTest('this is a print test string')
print list
pycallgraph.make_dot_graph('test.png')