[Python-Dev] time.clock() on windows

Kristján Valur Jónsson kristjan at ccpgames.com
Thu Oct 22 01:05:58 CEST 2009

> Presumably you could fake something like this by combining output from
> an initial time(), an initial QueryPerformanceCounter() and the
> current QueryPerformanceCounter(). But it makes more sense to
> understand why someone chose to implement time.clock() on Windows the
> way they did -- this seems very broken to me, and I think it should be
> changed.

Yes.  The problem with QPC is that although it has very high resolution, it is not precise in the long term.  And GetSystemTimeAsFileTime() is high precision in the long term but only updated evey 20ms or so.
In EVE Online we use a combination of the two for high resolution, long term precision.  But I'm not happy with the way I'm doing it.  It needs some sort of smoothing of course.  I've even played with using Kalman filtering to do it...
The idea is to use the low frequency timer to apply correction coefficients to the high frequency timer, yet keep the flow of time smooth (no backwards jumps because of corrections.).  An optimal solution has so far eluded me.



More information about the Python-Dev mailing list