High-resolution timers

Tim Roberts timr at probo.com
Fri Jan 18 00:21:57 EST 2002

"Tim Peters" <tim.one at home.com> wrote:
>Python's time.clock() (but not C's clock()!) on Windows updates 1,193,180
>times per second on most boxes, more often on some, and "beats me" under
>64-bit Windows.  Unlike as on Unix, time.clock() deltas measure wall-clock
>time on Windows, not user time (ya, ya, it's really derived indirectly from
>the Pentium's cycle counter, but "wall-clock time" captures the high-order

On an NT system with a multiprocessor HAL, it does actually use the cycle
counter.  On uniprocessor HAL NT systems and on Win 9X, it actually uses
the motherboard interval countdown timer which, as you have noted, runs at
1,193,182 Hz.

The astute reader who knows that the interval timer has a 16-bit countdown
value will note that 1193182/65536 = the magical 18.2 Hz.
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.

More information about the Python-list mailing list