Visual callgraph in Python

Sometimes a picture tells more than... Not often in programming though, but occasionally a picture does tell a little more than text and numbers can do (especially when the text and numbers are included in the picture).

Recently I found myself in need of a visual representation of a callgraph of a webapp written in Django. This was a pretty simple exercise creating a middleware that makes use of pycallgraph. The only heads-up is to make use of filters, exclude and/or include, or you'll end up with a *huge* pitcure.

I wrote a snippet to share. Using Django or not, that small piece of code shows how easy it is to make use of pycallgraph.

Basically it's just:

import pycallgraph
pycallgraph.start_trace()
call_to_the_main_code()
pycallgraph.make_dot_graph('callgraph.png')

As said I recommend making use of a filter though.


Kommentarer

Kommentera inlägget här:

Namn:
Kom ihåg mig?

E-postadress: (publiceras ej)

URL/Bloggadress:

Kommentar:

Trackback
RSS 2.0