Profiling?

14 views
Skip to first unread message

Ian Ozsvald

unread,
May 3, 2011, 5:17:02 AM5/3/11
to shedskin...@googlegroups.com
In a week I'm giving a show-n-tell to the London Financial Python
Usergroup on profiling using RunSnake and line_profiler. This is a
test for a bit of my EuroPython tutorial.

I'm thinking of throwing in some results for PyPy, ShedSkin and Cython
to show "here's what you can achieve after you've done your
profiling". But...I'm not sure how to go about profiling the ShedSkin
C++ code. Has anyone tried?

I'm guessing that something like cachegrind might do the job (though
I've never used the *grind toolset). Is there an easy tool that shows
the time spent on each line for the generated C++, preferably linked
to the annotated Python source?

Ian.

--
Ian Ozsvald (A.I. researcher, screencaster)
i...@IanOzsvald.com

http://IanOzsvald.com
http://SocialTiesApp.com/
http://MorConsulting.com/
http://blog.AICookbook.com/
http://TheScreencastingHandbook.com
http://FivePoundApp.com/
http://twitter.com/IanOzsvald

Jérémie Roquet

unread,
May 3, 2011, 6:07:44 AM5/3/11
to shedskin...@googlegroups.com
Hi Ian,

2011/5/3 Ian Ozsvald <i...@ianozsvald.com>:


> In a week I'm giving a show-n-tell to the London Financial Python
> Usergroup on profiling using RunSnake and line_profiler. This is a
> test for a bit of my EuroPython tutorial.
>
> I'm thinking of throwing in some results for PyPy, ShedSkin and Cython
> to show "here's what you can achieve after you've done your
> profiling". But...I'm not sure how to go about profiling the ShedSkin
> C++ code. Has anyone tried?
>
> I'm guessing that something like cachegrind might do the job (though
> I've never used the *grind toolset). Is there an easy tool that shows
> the time spent on each line for the generated C++, preferably linked
> to the annotated Python source?

Try callgrind (profiler) + kcachegrind (profiling's output
visualizer), it rocks :-)

Linking the results to the Python source would not be that easy —
though it's most of the time straightforward for who knows the code.

Please note that you may encounter some problems with the valgrind
suite, because of boehm gc…

Best regards,

--
Jérémie

Thomas Spura

unread,
May 3, 2011, 6:49:34 AM5/3/11
to shedskin...@googlegroups.com, i...@ianozsvald.com
On Tue, 3 May 2011 10:17:02 +0100
Ian Ozsvald wrote:

> In a week I'm giving a show-n-tell to the London Financial Python
> Usergroup on profiling using RunSnake and line_profiler. This is a
> test for a bit of my EuroPython tutorial.
>
> I'm thinking of throwing in some results for PyPy, ShedSkin and Cython
> to show "here's what you can achieve after you've done your
> profiling". But...I'm not sure how to go about profiling the ShedSkin
> C++ code. Has anyone tried?
>
> I'm guessing that something like cachegrind might do the job (though
> I've never used the *grind toolset). Is there an easy tool that shows
> the time spent on each line for the generated C++, preferably linked
> to the annotated Python source?

Hi Ian,

I usually compile with "-g" or make the _debug target and watch the
profile with gprof, e.g.:

shedskin test.py
make test_debug
gprof ./test_debug | less

Thomas

Ian Ozsvald

unread,
May 3, 2011, 7:19:37 AM5/3/11
to shedskin...@googlegroups.com
Jérémie, Thomas - thanks for the advice. I've never tried the *grinds
or g++ -g, it'll be fun to give them a go.
Cheers,
Ian.

--

Mark Dufour

unread,
May 3, 2011, 7:27:45 AM5/3/11
to shedskin...@googlegroups.com
shedskin test.py
make test_debug
gprof ./test_debug | less

I personally like to visualize the gprof results with gprof2dot:

http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
 
gprof2dot can also be used to profile the original python code, so it's easy to compare before and after.


mark.
--
http://www.youtube.com/watch?v=E6LsfnBmdnk

Reply all
Reply to author
Forward
0 new messages