logging module -- better timestamp accuracy on Windows

Brian Curtin brian.curtin at gmail.com
Wed Feb 16 12:02:45 EST 2011


On Wed, Feb 16, 2011 at 09:34, sturlamolden <sturlamolden at yahoo.no> wrote:

> On 16 Feb, 15:30, benhoyt <benh... at gmail.com> wrote:
>
> > It seems to me that the logging module should use a millisecond-accurate
> timestamp (time.clock) on Windows, just like the "timeit" module does.
>
> AFAIK, the Windows performance counter has long-term accuracy issues,
> so neither is perfect. Preferably we should have a timer with the long-
> term accuracy of time.time and the short-term accuracy of time.clock.
>
> Sturla


I just uploaded a timer extension I wrote a while back which tries to solve
some of this: http://pypi.python.org/pypi/timer (supports Python 2 and 3)

It takes an idea from MSDN Magazine about creating reliable and accurate
high resolution timers and converts it into somewhat of a threading.Timer
replacement. It accepts a duration in microseconds and can be stopped,
giving you the current elapsed microseconds. I should add an infinite
argument so it can be used more like a stopwatch, rather than requiring a
duration.

It appears to be fairly accurate so far, but I wouldn't count lives on it
just yet.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110216/1cf3a8ca/attachment.html>


More information about the Python-list mailing list