time.clock() in unix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MaxLindquist
    New Member
    • Oct 2006
    • 24

    #1

    time.clock() in unix

    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:

    Code:
    import time
    
    t1=time.clock()
    
    g=raw_input("Wait a sec and press enter")
    
    t2=time.clock()
    
    print t2-t1

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

    Thanks!
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    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 QueryPerformanc eCounter(). The resolution is typically better than one microsecond.

    Comment

    Working...