Python Call Graph 0.4.0

I’ve just released pycallgraph 0.4.0. It has several major new features including a command line interface and measuring accumulative time per function.

The 0.4.0 pycallgraph CLI supports function filtering, timing filtering, maximum stack level and a few more settings. For example, to do a simple call graph on “”: mygraph.png

Here’s an example that doesn’t include the class Foo and outputs to a SVG file format: –exclude=”*.Foo.*” –image-format=svg myfile.svg

Turns out far easier than modifying your source code to create a call graph.

Here’s one of the graphs from the source code examples

Orange Green Example

As you can see it has green and orange gradients. One end of the gradient is green because of the number of calls is high and the other is orange because the function calls are taking the longest. All that with a function that looks like this:

def orange_green(calls, total_time):
    """Make a higher total time have an orange colour and a higher number
    of calls have a green colour using RGB.
    return '#%02X%02X%02X' % (
        0x30 + total_time * 0xc0,
        0x30 + calls * 0xc0 + total_time * 0x70,

I hope it’s useful to you!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>