Problems with profiling results (hotshot or normal) : almost allare incorrect

I

Irmen de Jong

Hello
I haven't received any responses on my original posting,
and it could very well be that it never made it to the newsgroup
(because I can't find it back on my news server here).
So I'm posting this again. Sorry if it *did* make it to
the group.. Please consider trying my test-program that is given
here and let me know how it works on your python installation.

Thanks for any insight on this.

--Irmen

[original message follows]
 
B

Bengt Richter

Hello
I haven't received any responses on my original posting,
and it could very well be that it never made it to the newsgroup
(because I can't find it back on my news server here).
So I'm posting this again. Sorry if it *did* make it to
the group.. Please consider trying my test-program that is given
here and let me know how it works on your python installation.

Thanks for any insight on this.
Traceback (most recent call last):
File "C:\pywk\clp\irmen2.py", line 86, in ?
import hotshot, hotshot.stats, wait
ImportError: No module named wait

Where does wait come from?

Regards,
Bengt Richter
 
I

Irmen de Jong

Bengt said:
Traceback (most recent call last):
File "C:\pywk\clp\irmen2.py", line 86, in ?
import hotshot, hotshot.stats, wait
ImportError: No module named wait

Where does wait come from?

Aww, terribly sorry. Should test any code that I post.
(I called the test script "wait.py" on my system, that's
why it worked here, locally)

Here's a fixed version:

import time

def foo():
# idle wait loop
time.sleep(0.5)
def bar():
# busy (CPU) wait loop
s=time.time()
while time.time()<(s+0.5):
pass

def test():
for i in range(10):
foo()
bar()

if __name__=="__main__":
import hotshot, hotshot.stats
import profile, pstats

print "HOTSHOT profiling..."
prof = hotshot.Profile("wait.prof")
prof.runcall(test)
prof.close()
print "PROFILE DONE"
stats = hotshot.stats.load("wait.prof")
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(40)

print "Normal profiler..."
profile.run('test()', 'wait.prof')
print "profile done"
stats = pstats.Stats('wait.prof')
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(40)
 

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

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top