Azimout's Linux weblog

Profiling your Python programs

with one comment

cProfile is written in C (low overhead) and included in the Python standard library:

sudo aptitude install python-profiler and then run python -m cProfile -s cumulative

If you want per-line statistics of your code, download the line_profiler:

Get the .tar.gz, as the mercurial tree FTBFS (gcc: _line_profiler.c: No such file or directory), extract and run sudo python install

(If you get a gcc error about not finding Python.h, you need to install python-dev)

Then run and then python -m line_profiler


Written by azimout

28/02/2011 at 16:34

Posted in Howto

One Response

Subscribe to comments with RSS.

  1. […] written before about ways to profile your Python code. Here’s also a good guide with tips on Python performance […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: