Python Profiler Trouble

  • Thread starter Scott Brady Drummonds
  • Start date
S

Scott Brady Drummonds

Hi, everyone,

I have a tool I've written in Python that is taking many hours to run but I
believe could be running in less than an hour with a more clever
implementation. As such, I'm trying to use the profiler to spot the weak
points.

However, when following the instructions for using the profiler at
http://www.python.org/doc/current/lib/profile.html, I'm not having any luck.
I've tried letting the program run for about five or ten minutes then
killing it with ^C but no useful data are returned:

<quote>
Tue Feb 24 14:40:38 2004 prof

3 function calls in 0.000 CPU seconds

Random listing order was used

ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000
profile:0(marple.main('iecr_new_config.txt'))
1 0.000 0.000 0.000 0.000 <string>:1(?)
0 0.000 0.000 profile:0(profiler)
1 0.000 0.000 0.000 0.000 marple.py:10(main)


<pstats.Stats instance at 0xbd75fcc>
</quote>

Is this because I'm hitting ^C before it finishes? Do I have to let the
program run to completion to get good results? Since I don't want to wait
the many hours (or even many days) for this profiling info, is there a
better way that I can profile portions of the this large test case rapidly?

Thanks!
Scott
 
J

Josiah Carlson

Is this because I'm hitting ^C before it finishes? Do I have to let the
program run to completion to get good results? Since I don't want to wait
the many hours (or even many days) for this profiling info, is there a
better way that I can profile portions of the this large test case rapidly?

Use a smaller test case.
Profile smaller portions of the internals one at a time:

def funct():
funct1()
funct2()
funct3()

becomes

def funct():
profile('funct1()')
profile('funct2()')
profile('funct3()')

From here you should be able to figure the rest out.

- Josiah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top