python profiling for a XML parser program

Paul Boddie paul at boddie.org.uk
Sat Sep 19 22:05:42 CEST 2009


On 19 Sep, 21:19, MacRules <MacRu... at none.com> wrote:
>
> Is there a python profiler just like for C program?
> And tell me which functions or modules take a long time.
>
> Can you show me URL or link on doing this task?

Having already looked at combining Python profilers with KCachegrind
(as suggested by Andrew Dalke at EuroPython 2007), I discovered the
following discussion about the tools required:

http://ddaa.net/blog/python/lsprof-calltree

I found the following script very convenient to generate profiler
output:

http://www.gnome.org/~johan/lsprofcalltree.py

You can then visualise the time spent by just passing the output file
to KCachegrind:

http://kcachegrind.sourceforge.net/html/Home.html

The map of time spent in each function is extremely useful, I find.

Paul



More information about the Python-list mailing list