New Website Launched!

Slowchop Studios now has a new look to the brand, including a cool new snail logo.

We are also looking for contract work for any type of short to medium term projects. This includes game development, Python, Android, and a wide variety of technologies. Contact us if you wish to get a quote and discuss the work.

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 “myfile.py”:

pycallgraph-dot.py myfile.py mygraph.png

Here’s an example that doesn’t include the class Foo and outputs to a SVG file format:

pycallgraph-dot.py –exclude=”*.Foo.*” –image-format=svg myfile.py 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 colours.py:

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,
        0x30,
    )

I hope it’s useful to you!