473,395 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

hotshot profiler: how to distinguish between cpu time and wait (idle)time?

Hi,
when using the hotshot profiler, I can see no difference in the
measurement of a function that is busy eating CPU cycles, and
a function that is blocking/waiting on IO (or sleeping)...

For instance I have this output:

3 function calls in 26.931 CPU seconds

Ordered by: internal time, call count
ncalls tottime percall cumtime percall filename:lineno(function)
1 13.465 13.465 13.465 13.465 testprof.py:5(cpu)
1 13.464 13.464 13.464 13.464 testprof.py:9(sleep)
1 0.002 0.002 26.931 26.931 testprof.py:12(main)
0 0.000 0.000 profile:0(profiler)

My test program (see below) consists of two functions called sequentially:
a cpu() function eating 13+ seconds of CPU cycles when calculating
sha-hashes, and a sleep() function that only has time.sleep(13) in it.

What would be really useful, is that the profiler would show that sleep()
is actually not doing *anything*, while cpu() is doing all the hard work.
I.E.: measure CPU-time, not user-time.

How do I do this? Is this possible? (I'm using Python 2.3.4)

Thanks!!
--Irmen de Jong.

--------------- test program ------------------
import hotshot, hotshot.stats
import time
import sha

def cpu():
for i in range(1000000):
a=sha.sha("abcdefghijklmnopqrstuvwxyz").hexdigest( )

def sleep():
time.sleep(13)

def main():
print "cpu..."
cpu()
print "sleep..."
sleep()
print "done"

prof = hotshot.Profile("/tmp/test.prof")
result = prof.runcall(main)
prof.close()
print "PROFILE DONE, result=",result,type(result)
stats = hotshot.stats.load("/tmp/test.prof")
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(20)

Jul 18 '05 #1
0 1569

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: los | last post by:
Hi, I'm trying to create a program similar to that of Google's desktop that will crawl through the hard drive and index files. I have written the program and as of now I just put the thread to...
1
by: buky | last post by:
How can I find and set an idle time when oracle database releases some objects (tables, etc.) or opened sessions?
1
by: jdph40 | last post by:
I am using Access 2002. I downloaded the forms sample database FrmSmp97.mdb from Microsoft and used the following code in the timer event of a hidden form in order to close a database if no...
2
by: henk | last post by:
I have a hard time to get the idle time only from my application. (a relogin box should appear after eg 1 min, when a user switch to word and start typing for 10min, the re-login should not appear....
33
by: ram.ragu | last post by:
hi i have problem to calculate idle time of cpu and if idle time is more then i have to shut down the system. can anyone tell me the idea to so that please
5
by: LG | last post by:
Hi, I have recently used the Microsoft that will detect idle time coding on my Access database and it works fine as long as you do not add any data or move from one form to another. As soon as...
7
by: Nettan | last post by:
Hi everyone I want to now how long the computer is idle. Is there any easy way to do this in vb.net 2005. Before (in VB6) I checked if the mousepointer hade been moved. Thanks /Nettan
1
by: Visu | last post by:
Hi All! How to find the application idle time in VB.NET windows application? We can get the windows Idle time Private Declare Function GetLastInputInfo Lib "user32.dll" But i want the...
1
by: Debabrata Jana | last post by:
Hi, I am using Oracle 10g as a database server. I have two schema suppose s1 and s2. Suppose, I login to the s1 schema and as well as s2 schema. These two connection is active in two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.