[Python-talk] cProfile

Kent Johnson kent37 at tds.net
Wed Oct 14 20:43:13 EDT 2009


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


More information about the Python-talk mailing list