Do not use "profile", use "cProfile"

For those who didn't see the presentation at PyCon:

  • do not use the profile module with python 2.x
  • use the cProfile module (or hotshot if you're on < 2.4)

the profile module has extremely high overhead and will produce results that would have you doing the wrong thing if you were to believe them.  See Python list for why I bring this up now...

Comments

  1. Marius Gedminas

    Marius Gedminas on 05/03/2009 6:02 a.m. #

    A link to the PyCon presentation would be very welcome. (I hear there was more than one)

  2. Marius Gedminas

    Marius Gedminas on 05/03/2009 6:38 a.m. #

    Ah, here it is: http://us.pycon.org/2009/conference/schedule/event/15/

    Since I only read the slides and didn't watch the video, I missed the little "not profile, cProfile" note in a corner. And the "(Old “profile” module was pretty-much unusable because it would warp results so much)" note in the other slide.

  3. Jonathan Hartley

    Jonathan Hartley on 05/11/2009 5:27 p.m. #

    A belated thanks for the presentations - I was the baldy guy who came and chatted after the PyOpenGL one, you advised me about the traditional OpenGL API being a 'complete anti-pattern', and so today I finally finished the Orange Book, and feel like I should have read it years ago. Much inspiration gleaned. Many thanks!

    Also, your talk on cProfile could not have come at a better time - I had just added some functionality to a bedroom-coded 2D game project (http://code.google.com/p/sole-scion/) and was starting to see some slowdown. I ran cProfile on it at the back of the hall 10 minutes after your talk finished, and discovered that 80% of the execution time was being spent in one single line of code. (an ill-advised slice of vertices across a ctypes boundary.) Fixing that was a five minute job and almost quadrupled my frame rate back to 60fps+ again. \o/

    Whaddya know, profiling works! :-)

    Many thanks,

    Jonathan

  4. Mike C. Fletcher

    Mike C. Fletcher on 05/13/2009 9:41 p.m. #

    Glad it was useful.

Comments are closed.

Pingbacks

Pingbacks are closed.