ANN: a new utility for Python developers

Erno Kuusela erno-news at erno.iki.fi
Tue Aug 21 10:05:25 EDT 2001


In article <mailman.998398653.29844.python-list at python.org>, Skip
Montanaro <skip at pobox.com> writes:

| The limitations of Unix's CPU time granularity and the single-task nature of
| Windows doesn't mean the semantics of time.clock should be broken to get
| higher resolution.  Besides, what about NT?  Doesn't it distinguish between
| tasks?

the windows time.clock() calls a win32 api function that reads the
time stamp counter register that x86 cpus have, and then divides it by
the number of time stamp counter ticks per second. the time stamp
counter does not stop at any point. i would guess that it works the
same on the dos-based windows versions and on the nt-based ones.

there are 2 things here and i am not sure which ones we are disagreeing
about.

1) it is usually better to use gettimeofday(2) than times(2) on unix for
timing code because times(2) has poor resolution and the user/system
time numbers are frequently gibberish.

2) the python time.clock() should return information based on 
gettimeofday(2) and not times(2) on unix.

i don't care much about 2), it is only slightly annoying to have
to check which platform you are on and call time.clock() or time.time()
accordingly in order to get good resolution. perhaps a new function
should be introduced.

  -- erno



More information about the Python-list mailing list