time.time or time.clock

Fredrik Lundh fredrik at pythonware.com
Sun Jan 13 23:15:55 CET 2008


John Machin wrote:

> AFAICT that was enough indication for most people to use time.clock on
> all platforms ...

which was unfortunate, given that time.clock() isn't even a proper clock 
on most Unix systems; it's a low-resolution sample counter that can 
happily assign all time to a process that uses, say, 2% CPU and zero 
time to one that uses 98% CPU.

 > before the introduction of the timeit module; have you considered it?

whether or not "timeit" suites his requirements, he can at least replace 
his code with

     clock = timeit.default_timer

which returns a good wall-time clock (which happens to be time.time() on 
Unix and time.clock() on Windows).

</F>




More information about the Python-list mailing list