[Python-bugs-list] time.sleep() interferes with time.clock() (PR#321)
guido@python.org
guido@python.org
Tue, 9 May 2000 22:30:01 -0400 (EDT)
> Full_Name: Steven Brooks
> Version: 1.5.2
> OS: Linux
> Submission from: cd834592-a.ctjams1.mb.wave.home.com (24.108.113.70)
>
>
> Test Case:
> import time
> for i in range(100000): time.sleep(1) ; print time.clock()
>
> Expected Behaviour:
> clock() should increment by 1 after each call to sleep()
>
> Actual Behaviour:
> clock() does not seem to increment at all!
>
> Output:
> 0.07
> 0.07
> 0.07
> 0.07
> 0.07
> (etc. etc.)
>
> This is either a bug, or a documentation error. The library manual does
> not seem to say or imply that time.sleep() should interfere with time.clock().
It's not a bug. On Unix, clock() counts "CPU time", and a sleep
doesn't increment the CPU time (the CPU is given to another process).
On Windows, clock() *does* count real time -- there's no sufficiently
accurate CPU time available on that platform.
The documentation (http://www.python.org/doc/current/lib/module-time.html)
does mention CPU-time -- so I'm not sure what you want changed?
--Guido van Rossum (home page: http://www.python.org/~guido/)