Monday, March 25, 2013

Python profiling trials

Python comes with some default profiling capabilities. However, as also noted here, this profiling can slow down your program to a crawl making the gathering of useful statistics very tedious. Although it is very easy to get the proposed alternative "plop" running the output it generates is very limited and I did not find a description to get a more traditional output from this profiler. Although statprof does generate traditional output without slowing down running your program very much, it does not really seem to deal correctly with wrapper functions which severely limits its applicability to my typical programs. Thus, unfortunately, I seem to be stuck with using CProfile for a while.

A nice introduction to CProfile is given on slippen's blog.

To turn on profiling of Cython code add the line

#cython: profile=True

to the top of your .pyx file (including the hash).

No comments:

Post a Comment