[SciPy-user] Matlab style line based profiling

Robert Kern robert.kern@gmail....
Mon Feb 2 10:48:44 CST 2009


On Mon, Feb 2, 2009 at 05:36, David Baddeley
<david_baddeley@yahoo.com.au> wrote:
> Hi all,
>
> a while ago I drummed up a matlab like profiling module which gives times for individual lines. Since then I've found http://packages.python.org/line_profiler/  which seems to be a bit more refined and should be somewhat faster (mine is pure python, both hook the tracing functions). Where my code does have an advantage is that I've got it producing syntax highlighted html with the most expensive lines highlighted in red with the times in the margin, like the matlab profiler. I've also used a variant of the profile on, profile off, profile report syntax which should be familiar to matlab users.
>
> Would like to make it available, but am not sure how much demand there would be for a second line profiler module and whether it wouldn't be more sensible to see if the report generation couldn't be adapted to work with the aforementioned line_profiler module (there might be licensing issues here as my html generation borrows heavily from a GPL licensed python syntax highlighter and I'm not sure if Robert would be keen on having his module tainted).

Not much!  :-)

However, there is a version of the colorization code that you used
that is more palatably licensed:

  http://code.activestate.com/recipes/52298/

Here is IPython's version, which uses ANSI escape sequences for
terminal color output, which would also be a nice addition to the text
output:

  http://bazaar.launchpad.net/~ipython-dev/ipython/trunk/annotate/head%3A/IPython/PyColorize.py

I would be happy to accept contributions in this vein. I was gearing
up to release 1.0b2 in the next day or two, but if you would like to
get a patch together in the next week, I can wait.

Let me know if the default line_profiler workflow doesn't work well
for you. If you have suggestions for alternatives, I'm happy to
listen.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the SciPy-user mailing list