[Python-talk] Fw: cProfile

bruce.labitt at autoliv.com bruce.labitt at autoliv.com
Thu Oct 15 09:09:20 EDT 2009


----- Forwarded by Bruce Labitt/AEL/ASP on 10/15/2009 09:08 AM -----

Bruce Labitt/AEL/ASP wrote on 10/15/2009 09:06:27 AM:

> python-talk-bounces at dlslug.org wrote on 10/14/2009 08:43:13 PM:
> 
> > On Wed, Oct 14, 2009 at 6:58 PM, Bruce Labitt
> > <bruce.labitt at myfairpoint.net> wrote:
> > > It struck me that what I really want to do is run a profile on my 
python
> > > client code. The example given at
> > > http://docs.python.org/library/profile.html is that of profiling the 
object
> > > foo().
> > >
> > > I'd like to profile my whole routine.  Say it is called 
fftclient.py, and we
> > > are using ipython.  At the command line would be
> > >
> > >>> import cProfile
> > >>> cProfile.run('  ??? ','fftclientprof')
> > >>> import pstats
> > >>
> > >> > p = pstats.Stats('fftclientprof')
> > >> > p.sort_stats('time').print_stats(10)
> > >
> > > What would go in ??? __main__? I'm confused about this...
> > 
> > What is in fftclient.py? If it is a module with a main() function, 
then
> > import fftclient
> > cProfile.run('fftclient.main()','fftclientprof')
> > 
> > Kent
> 
> There isn't a main().  Just loads of functions, a couple of classes. 
> Last part of file is:
> 
> if __name__=='__main__':
>  init stuff
>  while ii<problemsize:
>   build_waveform
>   commandsequencer
>   ii = ii + 1
> 
> cProfile.run('fftclient.__main__','fftclientprof')  ??? or ???
> 
> -Bruce

******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail.  Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************


More information about the Python-talk mailing list