System Clock

Jp Calderone exarkun at intarweb.us
Thu Nov 6 22:26:07 EST 2003


On Fri, Nov 07, 2003 at 12:40:37AM +0000, James Harriman wrote:
> Hi,
> 
> I need to be able to measure a time interval in milliseconds on a windows
> machine. I have tried using time.clock() but it appears to measure time in
> seconds...Is there a way to measure time more precisely?

  From http://www.python.org/doc/lib/module-time.html

    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. 

    time()
        Return the time as a floating point number expressed in seconds since
    the epoch, in UTC. Note that even though the time is always returned as a
    floating point number, not all systems provide time with a better precision
    than 1 second. While this function normally returns non-decreasing values,
    it can return a lower value than a previous call if the system clock has
    been set back between the two calls.

  Jp





More information about the Python-list mailing list