time.clock() always returns 0?

Stephen Robert Norris srn at fn.com.au
Sun Jun 11 19:39:07 EDT 2000


In article <GEL05.4911$HD6.127120 at iad-read.news.verio.net>, "Doug Fort"
<dougfort at downright.com> wrote:
> On my system (RedHat Linux 6.2 Python 1.5.2 as shipped with RedHat)
> time.clock() always returns 0.  time.time() returns a good value.  Is
> this known behavior?  Am I doing something wrong?

time.clock() returns the amount of CPU time consumed since startup or the
last time.clock() call, not anything to do with the current time.

>>> print time.clock.__doc__
clock() -> floating point number

Return the CPU time or real time since the start of the process or since
the first call to clock().  This has as much precision as the system
records.

However, on my RH6.2 machine, the first call gave me:

>>> import time 
>>> time.clock()
0.05

This is on a PIII 533, so unless your CPU is _really_ fast, you should get
some CPU usage!

	Stephen




More information about the Python-list mailing list