By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

time.clock() in unix

P: 24
I wanna make a stopwatch. I did this on windows and it worked perfectly. When then used the same program on Unix it didn't work. I have checked in the pythonlibrary, but i can't find anything.

This is my simple code:

Expand|Select|Wrap|Line Numbers
  2. import time
  4. t1=time.clock()
  6. g=raw_input("Wait a sec and press enter")
  8. t2=time.clock()
  10. print t2-t1

Why does this work on windows, but not on Unix?

Nov 30 '06 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 6,596
clock( )
On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of ``processor time'', depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms.

On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond.
Dec 1 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.