All | 43 Folders | Accessibility | BoingBoing | Books | Computer Related | Family | Films | General | Hacking | Hobbies | Humor | Java | Links | Omni | OpenSolaris | Puzzles and Games

« Pinewood Derby Racin... | Main | I Want A Linux/Unix... »
20070213 Tuesday February 13, 2007

Orca Python Call Graph

Yesterday I saw a link on popurls.com to pycallgraph, a Python library that will generate call graphs and thought that I'd give it a try with Orca

I had to wait until today to download it, as being popular knocked out their server. I also had to install Graphviz, a prerequisite. That was easy. Just a few clicks away via the Synaptic Package manager on my Ubuntu system.

Integrating the pycallgraph code into Orca was trivial. Two lines near the start of the application:

import pycallgraph
pycallgraph.start_trace()

and then two lines just before it terminates:

pycallgraph.stop_trace()
pycallgraph.make_graph('orca-call-graph.png')

Creating the call graph counts is very CPU and memory intensive, so I then had to make a couple other adjustments to the Orca code, to convince it that it hadn't commited suicide:

If anybody else is interested, here's the full set of diffs I had to make to Orca.

As Orca was pretty much unusable whilst these statistics were being instrumented, I just started up Orca and once it had fully started, I then just terminated it.

That generated a 16188 x 4187 PNG Orca call graph image, which is quite awkward to view.

Although it's interesting and quite clever (and probably very helpful with small, simple Python applications), I think in order to be useful with Orca, the call graph data needs to be in a different format. Maybe just plain old ASCII table entry. Bonus points if it can do a function tree hierarchical view usage in ASCII too. I also wonder whether this is something that an appropriate set of DTrace probes would solve, so much more simply.

Any good simple alternative Python call graph packages out there?

[]

[]

[]

( Feb 13 2007, 11:12:41 AM PST ) [Listen] Permalink Comments [3]

Comments:

I think you should be able to generate graphs in other formats pycallgraphs.. with the format option on the make_graph method. At least ps should be available.

Posted by 62.142.195.131 on February 15, 2007 at 05:18 AM PST #

oh. the correct method is make_dot_graph :P

Posted by 62.142.195.131 on February 15, 2007 at 05:24 AM PST #

Thanks 62.142.195.131, or may I call you 62? If I feel a HackAttack(TM) coming on tomorrow, I'll know just where to look.

Posted by Rich Burridge on February 15, 2007 at 07:52 AM PST #

Post a Comment:

Comments are closed for this entry.